Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NetCDFCFReader support Network Common Data Form #6027

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

tkoyama010
Copy link
Member

@tkoyama010 tkoyama010 commented May 4, 2024

Overview

Add NetCDFCFReader support Network Common Data Form.

import pyvista as pv
from pyvista import examples
filename = examples.download_tos_O1_2001_2002(load=False)
reader = pv.get_reader(filename)
grid = reader.read()
grid.set_active_scalars("tos")
grid.plot()

image

Details

@pyvista-bot pyvista-bot added the enhancement Changes that enhance the library label May 4, 2024
@tkoyama010 tkoyama010 changed the title Add NetCDFReader support Network Common Data Form Add NetCDFCFReader support Network Common Data Form May 4, 2024
Copy link

codecov bot commented May 4, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 96.97%. Comparing base (06e7a8f) to head (2e1b830).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #6027    +/-   ##
========================================
  Coverage   96.96%   96.97%            
========================================
  Files         141      141            
  Lines       24532    24655   +123     
========================================
+ Hits        23788    23909   +121     
- Misses        744      746     +2     

@tkoyama010 tkoyama010 marked this pull request as ready for review May 4, 2024 06:40
@tkoyama010
Copy link
Member Author

@pyvista-bot preview

@tkoyama010
Copy link
Member Author

@pyvista-bot preview

@tkoyama010
Copy link
Member Author

@pyvista-bot preview

@pyvista-bot
Copy link
Contributor

@pyvista-bot
Copy link
Contributor

@pyvista-bot
Copy link
Contributor

@tkoyama010 tkoyama010 requested a review from bjlittle May 4, 2024 10:08
@tkoyama010
Copy link
Member Author

@bjlittle I guess you are interested in this reader.

@tkoyama010 tkoyama010 enabled auto-merge (squash) May 4, 2024 10:12
@tkoyama010 tkoyama010 disabled auto-merge May 4, 2024 10:13
@tkoyama010 tkoyama010 enabled auto-merge (squash) May 4, 2024 11:55
pyvista/core/utilities/reader.py Outdated Show resolved Hide resolved
pyvista/examples/downloads.py Outdated Show resolved Hide resolved
@bjlittle
Copy link
Contributor

bjlittle commented May 4, 2024

@tkoyama010 Yup, sure am ... But it's not clear to me how you control deserializing the variables in the NetCDF file into a mesh.

I'm guessing it's not truly generic and must conform to a specific format for the VTK reader.

I'll hit the VTK docs and look at the example NetCDF file ...

@tkoyama010 tkoyama010 marked this pull request as draft May 4, 2024 22:30
auto-merge was automatically disabled May 4, 2024 22:30

Pull request was converted to draft

Copy link
Contributor

@bjlittle bjlittle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tkoyama010 This looks like a great addition 😄

Note that, you should probably update the supported file types and readers in the doc-string of get_reader for the ".nc" supported files.

Also, as an aside, the example file that you load tos_O1_2001-2002.nc has a time dimension with 24 time steps ... is it possible to control from the NetCDFCFReader API which index in the time dimension will be loaded into the tos variable on the resultant mesh?

@tkoyama010
Copy link
Member Author

Note that, you should probably update the supported file types and readers in the doc-string of get_reader for the ".nc" supported files.

Thanks! Resolved in 50489ca.

Also, as an aside, the example file that you load tos_O1_2001-2002.nc has a time dimension with 24 time steps ... is it possible to control from the NetCDFCFReader API which index in the time dimension will be loaded into the tos variable on the resultant mesh?

Good idea! I'm checking to see if we can use any vtkNetCDFReader methods.

bjlittle
bjlittle previously approved these changes May 9, 2024
@bjlittle
Copy link
Contributor

bjlittle commented May 9, 2024

@tkoyama010 Once you've resolved your conflicts, then we can bank this pull-request 👍

I wouldn't expect you to extend the API of the reader in this pull-request to control features of the NetCDF reader ... save that for another time.

But I'd love to know whether you think this is easily possible and what it would involve.

@tkoyama010 tkoyama010 marked this pull request as ready for review May 11, 2024 00:02
@tkoyama010
Copy link
Member Author

tkoyama010 commented May 12, 2024

Also, as an aside, the example file that you load tos_O1_2001-2002.nc has a time dimension with 24 time steps ... is it possible to control from the NetCDFCFReader API which index in the time dimension will be loaded into the tos variable on the resultant mesh?

I found it and will add it as property to this Reader.
Need to search more.

https://gitlab.kitware.com/vtk/vtk/-/blob/v9.3.0/IO/NetCDF/Testing/Python/NetCDFReader.py#L27

reader.SetVariableArrayStatus("tos",1)

@tkoyama010 tkoyama010 marked this pull request as draft May 13, 2024 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Changes that enhance the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants