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

Error in Plotting STOFS-3D-Atlantic Data #88

Closed
AtiehAlipour-NOAA opened this issue Apr 8, 2024 · 6 comments
Closed

Error in Plotting STOFS-3D-Atlantic Data #88

AtiehAlipour-NOAA opened this issue Apr 8, 2024 · 6 comments
Assignees

Comments

@AtiehAlipour-NOAA
Copy link

Hi, I am trying to use the Thalassa package to read and plot STOFS-3D-Atlantic outputs. While thalassa.open_dataset and thalassa.plot work fine with *schout_adcirc outputs, it does not plot other outputs required to visualize current output, such as stofs_3d_atl.t12z.f001_024.field2d.nc. Please see the plot below for an example. Any suggestions on how I can use thalassa.open_dataset and thalassa.plot to plot the data correctly? Thanks for your help and time.

image

image

@pmav99 pmav99 self-assigned this Apr 8, 2024
@pmav99
Copy link
Collaborator

pmav99 commented Apr 8, 2024

Hello Atieh

I am afraid we haven't really looked into 3D output.

Judging from the screenshots, my guess is that there is some issue with the element connectivity.

ds = xr.open_dataset("~/Downloads/stofs_3d_atl.t12z.n001_024.field2d.nc")
ds.dims
ds.SCHISM_hgrid_face_nodes.min().values
ds.SCHISM_hgrid_face_nodes.max().values

outputs

FrozenMappingWarningOnValuesAccess({'time': 24, 'nSCHISM_hgrid_node': 2654153, 'nSCHISM_hgrid_face': 5039151, 'nMaxSCHISM_hgrid_face_nodes': 3})
array(3, dtype=int32)
array(2653944, dtype=int32)

Do notice that the node connectivity only starts from 3 and only reaches up to 2653944 instead of 2654153.

So, it seems that these files don't contain the full mesh for whatever reason.


related: #61

@pmav99
Copy link
Collaborator

pmav99 commented Apr 8, 2024

You can try to copy the mesh connectivity from the schout_adcirc_* file and then it should might work. You will probably need to rename a bunch of dimensions though.

@AtiehAlipour-NOAA
Copy link
Author

@pmav99 Thank you so much for the great suggestion. I tried to use the format and names inside the shout_adcirc file and rename and replace values and dimensions in field2d.nc files.

First I read the nc files.
image

image

Then I renamed and replaced the dimensions and variables in field2d.nc files.

ds2= ds2.rename({'nSCHISM_hgrid_node': 'node', 'nSCHISM_hgrid_face': 'nele', 'nMaxSCHISM_hgrid_face_nodes': 'nvertex'})
ds2 = ds2.drop_dims('nele')
ds2['nele'] = ds['nele']
ds2['nvertex']=ds['nvertex']
ds2['element']= ds['element']
ds2= ds2.rename({'SCHISM_hgrid_node_x': 'x', 'SCHISM_hgrid_node_y': 'y'})
ds2

image

I normalized and cropped the data using Thalassa.

When I plot the data the depth values look OK, but for the rest of variables, there are a lot of missing data.

image

image

image

image

The same happens when I copy each variable to shout_adcirc file.

@pmav99
Copy link
Collaborator

pmav99 commented Apr 11, 2024

Hmm... The missing values seem to be on triangles that are over land. So it could be that some kind of mask is applied on the dataset. Have you checked if there are values there? I suspect that there are nans for elev etc.

Check the original netcdf files. Not the normalized datasets. E.g. with

ds_orig = xr.open_dataset(...)
ds_orig.isel(nSCHISM_hgrid_node=0).elev.values

If this is the case, this should also explain why these files contain a subset of the connectivity. The mask must have been applied there, too.

@AtiehAlipour-NOAA
Copy link
Author

@pmav99, you're correct. I looked into the nodes in the original dataset near the areas that show as nan in the plots, and it seems that most of them are nan. Thanks a lot for your help and time.

image

@pmav99
Copy link
Collaborator

pmav99 commented Apr 12, 2024

OK. I guess I will just close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants