asascience-open / xarray-subset-grid

Subset Xarray datasets in space
https://xarray-subset-grid.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

Add examples for subsetting STOFS outputs #16

Open AtiehAlipour-NOAA opened 4 months ago

AtiehAlipour-NOAA commented 4 months ago

Description

Add notebooks or example scripts for subsetting different STOFS outputs.

Below are example notebooks demonstrating how to subset the STOFS-3D-Atl data and visualize the resulting outputs:

https://github.com/AtiehAlipour-NOAA/Subsetting/blob/main/notebooks/KeyBridge_Visualization.ipynb https://github.com/AtiehAlipour-NOAA/Subsetting/blob/main/notebooks/KeyBridge_multiple_files.ipynb

The goal is to provide examples that users can easily follow to subset data for their specific STOFS datasets of interest.

mpiannucci commented 3 months ago

STOFS 2D example is now available here: https://github.com/asascience-open/xarray-subset-grid/blob/main/examples/stofs_2d.ipynb

AtiehAlipour-NOAA commented 3 months ago

STOFS 2D example is now available here: https://github.com/asascience-open/xarray-subset-grid/blob/main/examples/stofs_2d.ipynb

@mpiannucci Thanks for the update. I will run the example code. Can we use the same code for fields.cwl.nc, fields.swl.nc, and fileds.htp.nc? Thanks!

mpiannucci commented 2 months ago

Yes the code would be the same for all of them assuming that they all have the same metadata. The 3D cases will require #20 tho so will revisit when that is done

AtiehAlipour-NOAA commented 1 month ago

@mpiannucci and @omkar-334 @ChrisBarker-NOAA Thank you again for providing these amazing example codes for STOFS data. I was able to install the xarray-subset-grid package and use the STOFS-2D code to run a few examples. I have a few observations and suggestions:

image

AtiehAlipour-NOAA commented 1 month ago

@omkar-334, I was trying to test the STOFS-2D code and want to reuse the selector for an SWL file. Shouldn't this be ds_swl instead?

image

If so, when I change it to ds_swl, I get this error:

image

AtiehAlipour-NOAA commented 1 month ago

@omkar-334, thanks for putting the STOFS example code together. I tried to run the STOFS-3D example with the operational data, but it doesn’t seem to be working as expected.

image image

omkar-334 commented 1 month ago

I've tried it on the operational data. The dataset you've mentioned (s3://noaa-nos-stofs3d-pds/STOFS-3D-Atl/stofs_3d_atl.20240822/stofs_3d_atl.t12z.fields.temperature_f001_012.nc) does not recognize any grid type.
image
image

Making it CF compliant doesnt work because there is no face dimension or face_node_connectivity. Should we build it?

Moreover, the Select function assumes that we are going to reuse the selector for the same grid class , i.e, Ugrid->Ugrid, RegularGrid -> RegularGrid
image
The operational temperature data only contains self._node_dimension (which is nSCHISM_hgrid_node) out of all the parameters.
So, here the appropriate subset operation should be image, which works.

Should we be checking if the parameters exist and accordingly apply the subset?

omkar-334 commented 1 month ago

For CWL -> SWL subsetting, the same issues occur.

Moreover, the Select function assumes that we are going to reuse the selector for the same grid class , i.e, Ugrid->Ugrid, RegularGrid -> RegularGrid

the CWL dataset is recognized as UGrid while the SWL is recognized as a RegularGrid. Both classes have different parameters and logic for the selector.

Making it CF compliant doesnt work because there is no face dimension or face_node_connectivity. Should we build it?

The SWL dataset doesn't have both face_node_connectivity and mesh_topology

AtiehAlipour-NOAA commented 1 month ago

@omkar-334, thanks for looking into this. The spatial grids for CWL and SWL are the same, similar to the temperature and out2d files. Since node connectivity is missing in some of the files, the idea was to read this information from files that include it, such as CWL for STOFS-2D and out2d for STOFS-3D. My understanding was that this was an automatic process: when we first read CWL and out2d files, the selector would collect this information, use the node information, and subset the data accordingly.

omkar-334 commented 1 month ago

By Grid type , I meant the Grids we have implemented in our code. There are 4 sub classes for the Selector - UGrid, SGrid, RegularGrid, RegularGrid2d.

Each subclass has different logic and parameters.

AtiehAlipour-NOAA commented 1 month ago

By Grid type , I meant the Grids we have implemented in our code. There are 4 sub classes for the Selector - UGrid, SGrid, RegularGrid, RegularGrid2d.

Each subclass has different logic and parameters.

@omkar-334, thanks for the clarification. Both CWL and SWL have ugrid type.

omkar-334 commented 1 month ago

@AtiehAlipour-NOAA Yes , you are right. I meant that even though both are UGrid, our code recognizes one as RegularGrid because of the missing connectivity

AtiehAlipour-NOAA commented 1 month ago

Would it be possible to refine the selector so that when we use it on CWL, it considers the node connectivity of CWL for the next file (SWL)? Alternatively, could we use assign_ugid_topology to provide those information? @ChrisBarker-NOAA @mpiannucci do you have any suggestions?