Closed sameerCoder closed 3 years ago
This error is coming from within matplotlib, not pyroms. You can search the web to find: [(https://github.com/matplotlib/basemap/issues/494)]
Rather than rewriting pyroms to use cartopy, we're planning to drop support at some point to write tools from scratch using xarray and other newer packages.
Hi, Thanks for such quick response but when i am importing matplotlib then no error is coming.
import matplotlib
NO Error
I think dedent is making some Error. How to make pyroms to use cartopy ? Thank you.
What are you hoping to use pyroms for?
Hi, Thanks for reply. I want to create Initial condition & Boundary Condition from GODAS data for that i need to import pyroms which is giving Error.
Wow, Basemap is used by the guts of hgrid. That is going to be tricky to clean up. However, your problems are just beginning, because for remapping, pyroms uses scrip, which is even more problematic. I'm sorry we're in this position, but pyroms truly does need replacing rather than fixing.
Hi, I just created one python file just to check all the modules are importing correctly or not. And the news is while importing i am getting the Errors.
`import matplotlib
matplotlib.use('Agg')
import subprocess
import os
import subprocess
import numpy as np
import pyroms
import pyroms_toolbox
from remap import remap
from remap_uv import remap_uv
`
Traceback (most recent call last):
File "modulesonly.py", line 8, in <module>
import pyroms
File "/home/user/Newfolder/pyroms/pyroms/pyroms/__init__.py", line 14, in <module>
from . import hgrid
File "/home/user/Newfolder/pyroms/pyroms/pyroms/hgrid.py", line 22, in <module>
from mpl_toolkits.basemap import Basemap
File "/home/user/anaconda3/envs/pyroms1/lib/python3.8/site-packages/mpl_toolkits/basemap/__init__.py", line 46, in <module>
from .proj import Proj
File "/home/user/anaconda3/envs/pyroms1/lib/python3.8/site-packages/mpl_toolkits/basemap/proj.py", line 6, in <module>
from matplotlib.cbook import dedent
ImportError: cannot import name 'dedent' from 'matplotlib.cbook' (/home/user/anaconda3/envs/pyroms1/lib/python3.8/site-packages/matplotlib/cbook/__init__.py)
Can you guide me how to proceed to generate Initial condition & Boundary Condition from GODAS data.
I think line by line module Error i have to solve.
Is it possible for you to try other versions of Basemap? Or make the change suggested at https://github.com/matplotlib/basemap/issues/494?
Basemap is used to compute distances and azimuthal directions in pyroms. cartopy include geodesic and the inverse function, which are (I think) direct equivalent to the basemap function. It should come down to changing only a few lines to replace basemap with cartopy to have a working grid object. Cheers, Fred
On Thu, Feb 25, 2021 at 12:05 PM Kate Hedstrom notifications@github.com wrote:
Is it possible for you to try other versions of Basemap? Or make the change suggested at matplotlib/basemap#494 https://github.com/matplotlib/basemap/issues/494?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ESMG/pyroms/issues/32#issuecomment-786132611, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD3CYKKUKP5QNKXL7UJGJ3TA2NRNANCNFSM4YEOPHFA .
Thanks for reply to both Kshedstrom & fredc
@kshedstrom as per suggested in /basemap#494 i changed the line to from inspect import cleandoc as dedent
Didn't work out,
Even I am facing issue in importing hgrid module.
that is far apart from matplotlib.
Can i ask you, If all the modules problems are solved then I will be able to generate Initial condition and boundary condition with my GEODAS data. This Pyroms setup is good to go ?
Thank you.
That said, the steps used in pyroms to do interpolations to ROMS grids are the steps you would need to take with any tool. There's "flooding" to fill the land points with reasonable values, then horizontal remapping onto the ROMS grid, finally vertical remapping onto the ROMS vertical grid.
Hi, Sorry for late Reply @kshedstrom Actually GODAS is NCEP Global Ocean Data Assimilation System (GODAS) https://www.psl.noaa.gov/data/gridded/data.godas.html
Can you please guide me How to Replace Scrip to xESMF as i am also facing issue in Scrip as told by u, so i installed xESMF using - conda install -c conda-forge xesmf xESMF got installed successfully. Now please guide me how to proceed with xESMF.
Any help will be Highly Appreciated. Thank you.
Hi,
while running make_ic.py
I will really appreciate if any help
I am getting below remapping Error
(pyroms1) username@username-Desktop:~/Desktop/pyroms/examples/Yellow_Sea/Inputs/Initial$ python3 cpmake_ic_file.py
WARNING:root: scrip could not be imported. Remapping functions will not be available
Traceback (most recent call last):
File "cpmake_ic_file.py", line 11, in
import _remapping
ModuleNotFoundError: No module named '_remapping'
This is easy to fix, part of the migration to Python 3. Change it to:
from pyroms import _remapping
Are you trying to use scrip or ESMF? My husband just installed pyroms on his computer and he's not getting the scrip error.
Hi, I have installed Scrip also and i think i too installed successfully
Desktop:~/Desktop/pyroms/pyroms/external/scrip/source$ mv -vf scrip*.so ../../../pyroms
'scrip.cpython-38-x86_64-linux-gnu.so' -> '../../../pyroms/scrip.cpython-38-x86_64-linux-gnu.so'
But while running make_ic.py script I am getting warning from scrip , below is the warning line i am getting.
(pyroms1) username@username-Desktop:~/Desktop/pyroms/examples/Yellow_Sea/Inputs/Initial$ python3 cpmake_ic_file.py
**WARNING:root: scrip could not be imported. Remapping functions will not be available**
All Module installed successfully
Build IC file from the following file:
And coming to ESMF, that i have installed successfully and i have look into builtin function of ESMF module, i am not able to find remapping function, Can you guide me which function i have to import and which place i have to change the code for making ic and making boundary Thank you.
Look at what is done in the examples/Arctic_HYCOM_GLBy directory. It uses xesmf.
@kshedstrom Thanks for reply, sure i will look into it. :)
Hi @kshedstrom Can you let me know where i can find mention SODA file ((/center/w/kate/SODA/SODA_2.1.6_20071230-20080104.cdf) & (/center/w/SODA/SODA_grid.cdf)), so that i get confirmation my environment is good and for me the setup is working fine and according to that i can make my setup work. Please help me with sample files SODA_2.1.6_20071230-20080104.cdf , SODA/SODA_grid.cdf & other files which is required for making Initial condition & Boundary condition nc files.
I will really appreciate if any help. Thank you.
I no longer have those files, nor do I have a good way to transfer such large files to you. Instead, you should go to the source for the SODA files: https://www.soda.umd.edu/
HI, I got required soda files, Can you help me in getting yellow_sea_grid.nc. This link is little helpful for me https://www.myroms.org/forum/viewtopic.php?t=3408 but i was not able to find the yellow_sea_grid.nc file. Thank you.
Can you run make_YELLOW_grd_v1.py to create your own grid file? I'm afraid I no longer have that web site at ARSC as ARSC is no more.
HI, Thanks make_YELLOW_grd_v1.py i made working. Now problem is coming getting Error of [Errno 2] No such file or directory: b'remap_weights_SODA_2.1.6_to_YELLOW_bilinear_t_to_rho.nc' remap_weights_SODA_2.1.6_to_YELLOW_bilinear_t_to_rho.nc ON internet i can not find this file nor in my pyroms directory. Can you please help me with this.
Before you can run make_ini_file.py, you have to run make_remap_weights_file.py. That should generate all your remapping weights files.
import pyroms WARNING:root: scrip could not be imported. Remapping functions will not be available (pyroms1) username@username-Desktop:~/Desktop/org_pyroms/examples/Yellow_Sea/Inputs/Initial$ python3 make_remap_weights_file.py WARNING:root: scrip could not be imported. Remapping functions will not be available
printing lon_t 2 lont shape (330, 720) yrange: 190 y 240 Assuming spherical is integer b'T' <class 'numpy.ma.core.MaskedArray'> Load geographical grid from file grid shape 122 142 grid shape 122 141 grid shape 121 142 Traceback (most recent call last): File "make_remap_weights_file.py", line 27, in
pyroms.remapping.compute_remap_weights(grid1_file, grid2_file, \ File "/home/username/python_learn_24feb2021/pyroms/pyroms/pyroms/remapping/compute_remap_weights.py", line 41, in compute_remap_weights pyroms.remapping.scrip.compute_remap_weights('compute_remap_weights_in') AttributeError: module 'pyroms.remapping' has no attribute 'scrip' (pyroms1) username@username-Desktop:~/Desktop/org_pyroms/examples/Yellow_Sea/Inputs/Initial$ python Python 3.8.5 (default, Sep 4 2020, 07:30:14) [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information. import pyroms WARNING:root: scrip could not be imported. Remapping functions will not be available print(dir(pyroms.remapping)) ['builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'path', 'spec', 'compute_remap_weights', 'flood', 'flood2d', 'logging', 'make_remap_grid_file', 'remap', 'remap2', 'roms2z', 'sta2z', 'test_remap_weights', 'z2roms']
I think the only option for me now is to use ESMF Module and check its working on examples/Arctic_HYCOM_GLBy directory Isn't it? :( or can you guide me how to solve below scrip error. AttributeError: module 'pyroms.remapping' has no attribute 'scrip' Thank you.
@hadfieldnz was working on making scrip work. I had gotten it to work before, but not recently. Yes, give ESMF a go, it is the modern way to go.
ok I will try ESMF but through scrip module work i was almost near to final step of creating initial condition & boundary condition.
HI, I am trying now Arctic_HYCOM directory, I have downloaded few nc files from http://tds.hycom.org/thredds/catalog.html website, Can you please let me know whether below nc file i can use as grid file ?
**~/Desktop/org_pyroms/examples/Arctic_HYCOM$ ncdump -h latestgrid.nc4**
netcdf latestgrid {
dimensions:
time = 1 ;
lat = 4251 ;
lon = 4500 ;
depth = 40 ;
variables:
float salinity_bottom(time, lat, lon) ;
salinity_bottom:_CoordinateAxes = "time_run time lat lon" ;
salinity_bottom:units = "psu" ;
salinity_bottom:long_name = "Salinity" ;
salinity_bottom:standard_name = "sea_water_salinity_at_bottom" ;
salinity_bottom:NAVO_code = 16 ;
salinity_bottom:coordinates = "time_run time lat lon lat lon" ;
double time_run(time) ;
time_run:long_name = "run times for coordinate = time" ;
time_run:standard_name = "forecast_reference_time" ;
time_run:calendar = "proleptic_gregorian" ;
time_run:units = "hours since 2021-03-16 12:00:00.000 UTC" ;
time_run:missing_value = NaN ;
time_run:_CoordinateAxisType = "RunTime" ;
double time(time) ;
time:long_name = "Forecast time for ForecastModelRunCollection" ;
time:standard_name = "time" ;
time:calendar = "proleptic_gregorian" ;
time:units = "hours since 2021-03-16 12:00:00.000 UTC" ;
time:missing_value = NaN ;
time:_CoordinateAxisType = "Time" ;
double lat(lat) ;
lat:units = "degrees_north" ;
lat:long_name = "Latitude" ;
lat:standard_name = "latitude" ;
lat:point_spacing = "even" ;
lat:axis = "Y" ;
lat:NAVO_code = 1 ;
lat:_CoordinateAxisType = "Lat" ;
double lon(lon) ;
lon:units = "degrees_east" ;
lon:long_name = "Longitude" ;
lon:standard_name = "longitude" ;
lon:modulo = "360 degrees" ;
lon:axis = "X" ;
lon:NAVO_code = 2 ;
lon:_CoordinateAxisType = "Lon" ;
float surf_el(time, lat, lon) ;
surf_el:_CoordinateAxes = "time_run time lat lon" ;
surf_el:units = "m" ;
surf_el:long_name = "Water Surface Elevation" ;
surf_el:standard_name = "sea_surface_elevation" ;
surf_el:NAVO_code = 32 ;
surf_el:coordinates = "time_run time lat lon lat lon" ;
float salinity(time, depth, lat, lon) ;
salinity:_CoordinateAxes = "time_run time depth lat lon" ;
salinity:units = "psu" ;
salinity:long_name = "Salinity" ;
salinity:standard_name = "sea_water_salinity" ;
salinity:NAVO_code = 16 ;
salinity:coordinates = "time_run time depth lat lon lat lon" ;
double depth(depth) ;
depth:units = "m" ;
depth:long_name = "Depth" ;
depth:standard_name = "depth" ;
depth:positive = "down" ;
depth:axis = "Z" ;
depth:NAVO_code = 5 ;
depth:_CoordinateAxisType = "Height" ;
depth:_CoordinateZisPositive = "down" ;
// global attributes:
:classification_level = "UNCLASSIFIED" ;
:distribution_statement = "Approved for public release. Distribution unlimited." ;
:downgrade_date = "not applicable" ;
:classification_authority = "not applicable" ;
:institution = "Fleet Numerical Meteorology and Oceanography Center" ;
:source = "HYCOM archive file" ;
:history = "archv2ncdf3z ;\nFMRC Best Dataset" ;
:field_type = "instantaneous" ;
:Conventions = "CF-1.4, NAVO_netcdf_v1.1" ;
:comment = "p-grid" ;
:cdm_data_type = "GRID" ;
:featureType = "GRID" ;
:location = "Proto fmrc:GLBy0.08_930_FMRC" ;
:History = "Translated to CF-1.0 Conventions by Netcdf-Java CDM (CFGridWriter2)\nOriginal Dataset = GLBy0.08/latest; Translation Date = 2021-03-22T09:15:31.119Z" ;
:geospatial_lat_min = -80. ;
:geospatial_lat_max = 90. ;
:geospatial_lon_min = 0. ;
:geospatial_lon_max = 359.920043945312 ;
}
and below nc file as my data file
**~/Desktop/org_pyroms/examples/Arctic_HYCOM$ ncdump -h sur.nc4**
netcdf sur {
dimensions:
time = 1 ;
lat = 4251 ;
lon = 4500 ;
variables:
float emp(time, lat, lon) ;
emp:standard_name = "water_flux_into_ocean" ;
emp:units = "kg/m2/s" ;
emp:_FillValue = 1.267651e+30f ;
emp:valid_range = -0.01518309f, 0.1502962f ;
emp:long_name = " surf. water flux [93.0H]" ;
emp:coordinates = "time lat lon lat lon" ;
double time(time) ;
time:long_name = "Valid Time" ;
time:units = "hours since 2000-01-01 00:00:00" ;
time:time_origin = "2000-01-01 00:00:00" ;
time:calendar = "gregorian" ;
time:axis = "T" ;
time:_CoordinateAxisType = "Time" ;
double lat(lat) ;
lat:long_name = "Latitude" ;
lat:standard_name = "latitude" ;
lat:units = "degrees_north" ;
lat:point_spacing = "even" ;
lat:axis = "Y" ;
lat:_CoordinateAxisType = "Lat" ;
double lon(lon) ;
lon:long_name = "Longitude" ;
lon:standard_name = "longitude" ;
lon:units = "degrees_east" ;
lon:modulo = "360 degrees" ;
lon:axis = "X" ;
lon:_CoordinateAxisType = "Lon" ;
float mixed_layer_thickness(time, lat, lon) ;
mixed_layer_thickness:standard_name = "ocean_mixed_layer_thickness" ;
mixed_layer_thickness:units = "m" ;
mixed_layer_thickness:_FillValue = 1.267651e+30f ;
mixed_layer_thickness:valid_range = 0.5037785f, 2941.156f ;
mixed_layer_thickness:long_name = "mix.layr.thickness [93.0H]" ;
mixed_layer_thickness:coordinates = "time lat lon lat lon" ;
float qtot(time, lat, lon) ;
qtot:standard_name = "surface_downward_heat_flux_in_air" ;
qtot:units = "w/m2" ;
qtot:_FillValue = 1.267651e+30f ;
qtot:valid_range = -1408.83f, 1030.314f ;
qtot:long_name = " surf. heat flux [93.0H]" ;
qtot:coordinates = "time lat lon lat lon" ;
float ssh(time, lat, lon) ;
ssh:standard_name = "sea_surface_elevation" ;
ssh:units = "m" ;
ssh:_FillValue = 1.267651e+30f ;
ssh:valid_range = -2.036391f, 1.634122f ;
ssh:long_name = " sea surf. height [93.0H]" ;
ssh:coordinates = "time lat lon lat lon" ;
float steric_ssh(time, lat, lon) ;
steric_ssh:units = "m" ;
steric_ssh:_FillValue = 1.267651e+30f ;
steric_ssh:valid_range = -1.988469f, 1.664126f ;
steric_ssh:long_name = " steric SSH [93.0H]" ;
steric_ssh:coordinates = "time lat lon lat lon" ;
float surface_boundary_layer_thickness(time, lat, lon) ;
surface_boundary_layer_thickness:units = "m" ;
surface_boundary_layer_thickness:_FillValue = 1.267651e+30f ;
surface_boundary_layer_thickness:valid_range = 0.9750289f, 1200.f ;
surface_boundary_layer_thickness:long_name = "bnd.layr.thickness [93.0H]" ;
surface_boundary_layer_thickness:coordinates = "time lat lon lat lon" ;
float u_barotropic_velocity(time, lat, lon) ;
u_barotropic_velocity:standard_name = "barotropic_eastward_sea_water_velocity" ;
u_barotropic_velocity:units = "m/s" ;
u_barotropic_velocity:_FillValue = 1.267651e+30f ;
u_barotropic_velocity:valid_range = -0.9733748f, 0.994167f ;
u_barotropic_velocity:long_name = " baro. u-vel. [93.0H]" ;
u_barotropic_velocity:coordinates = "time lat lon lat lon" ;
float v_barotropic_velocity(time, lat, lon) ;
v_barotropic_velocity:standard_name = "barotropic_northward_sea_water_velocity" ;
v_barotropic_velocity:units = "m/s" ;
v_barotropic_velocity:_FillValue = 1.267651e+30f ;
v_barotropic_velocity:valid_range = -1.435597f, 0.9408848f ;
v_barotropic_velocity:long_name = " baro. v-vel. [93.0H]" ;
v_barotropic_velocity:coordinates = "time lat lon lat lon" ;
// global attributes:
:Conventions = "CF-1.6" ;
:classification_level = "UNCLASSIFIED" ;
:distribution_statement = "Approved for public release. Distribution unlimited." ;
:downgrade_date = "not applicable" ;
:classification_authority = "not applicable" ;
:institution = "Fleet Numerical Meteorology and Oceanography Center" ;
:source = "HYCOM archive file" ;
:history = "archv2ncdf2d" ;
:comment = "p-grid" ;
:field_type = "instantaneous" ;
:History = "Translated to CF-1.0 Conventions by Netcdf-Java CDM (CFGridWriter2)\nOriginal Dataset = GLBy0.08/expt_93.0/sur; Translation Date = 2021-03-22T09:24:47.785Z" ;
:geospatial_lat_min = -80. ;
:geospatial_lat_max = 90. ;
:geospatial_lon_min = 0. ;
:geospatial_lon_max = 359.920043945312 ;
}
Really Thanks alot to @kshedstrom for helping me this much, please guide me little bit more.
You should instead look at the Arctic_HYCOM_GLBy directory. That's the one with ESMF.
Your first file can be used as the grid file. All you need (I think) is lat and lon, which are in both of your files. For the second file, it has ssh and the barotropic velocities. Is that all you need? If so, it should be fine. I usually interpolate from the full 3-d salinity, temperature and velocity in addition to ssh.
Hi, My only current requirement is to create Initial condition and Boundary condition. Inside Arctic_HYCOM_GLBy directory, i am not able to findout make_ic_file.py I am now using example directory as to make my system pyroms workable and to understand the flow of code. Thank you.
Hi, I have download all the ssh,salt,temp,u&v 3 days individual data and then merge all the nc files to single final HYCOM_GLBy0.08_uvsaltsshtemp_2019_0101_0103.nc file,
Please correct me and Now i am executing make_remap_weights_file.py
(pyroms2) user@user-Desktop:~/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy$ python3 make_remap_weights_file.py and i am getting below Error
(pyroms2) user@user-Desktop:~/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy$ python3 make_remap_weights_file.py
WARNING:root: scrip could not be imported. Remapping functions will not be available
Modules imported
MemoryError: Unable to allocate 4.53 GiB for an array with shape (120, 1126, 4500) and data type float64
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "make_remap_weights_file.py", line 10, in <module>
srcgrd = pyroms_toolbox.Grid_HYCOM.get_nc_Grid_HYCOM2('/home/user/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy/HYCOM_GLBy0.08_uvsaltsshtemp_2019_0101_0103.nc')
File "/home/user/Desktop/own_download_pyroms/pyroms/pyroms_toolbox/pyroms_toolbox/Grid_HYCOM/get_nc_Grid_HYCOM2.py", line 45, in get_nc_Grid_HYCOM2
bottom = pyroms.utility.get_bottom(var[::-1,:,:], mask_t[0], spval=var.fill_value)
File "/home/user/Desktop/own_download_pyroms/pyroms/pyroms/pyroms/utility.py", line 344, in get_bottom
bottom[:,:] = _interp.get_bottom(varz,mask,spval)
TypeError: __init__() missing 1 required positional argument: 'dtype'
Now which all files i required to created Initial condition and Boundary condition and i am not able to identify also here how to give grid data, In one python script i show myssh.sh script and grid.nc file, How to get these two myssh.sh, grid.nc files and ohter required files. Please guide me. Thank you.
MemoryError: Unable to allocate 4.53 GiB for an array with shape (120, 1126, 4500) and data type float64 This appears to be your problem. That's an awfully big grid to bite off for a first attempt.
@kshedstrom Inside Arctic_HYCOM_GLBy directory, i am not able to findout make_ic_file.py How to get make_ic_file.py In case of Arctic_HYCOM_GLBy directory I am little confuse which all input files to use, In case of Soda i understood that i have SODA parameters data ncfiles then SODA grid file with masking u v , yellow sea nc file then yellow sea grid file but in case of Arctic_HYCOM_GLBy directory which all input files are used i am not getting, how many grid files are there, which all nc files we are using i am not getting that ?
Any help will be Highly Appreciated. Thank you.
There should be two grid files, one for the data grid (GODAS, SODA) and one for your grid (Yellow sea?).
The initial condition is exactly like one record of a climatology file. From HYCOM I would make an initial condition from one daily file while I'd use monthly means for a climatology. Just copy make_clm_file.py and edit it to point to just one daily input file.
okay, so no use of downloading the HYCOM_GLBy0.08_salt_2019_0101_0103.nc using get_hycom_GLBy0.08_salt_2019_rob.py inside make_clm_file.py i can point the big grid data of SODA data and my small grid data of Yellow sea, isn't it ?
Thank you very much.
If you can get these scripts to work for any global ocean model files you have, you should be good to go.
Hi @kshedstrom , Can you please let me know How to solve below Error, While creating destination file below error i am getting, few of data is also created in destination file.
Creating destination file ./Godas_uvsshts_jan_2019__u_clim_GODASROMS.nc
/home/username/Desktop/own_download_pyroms/pyroms/pyroms_toolbox/pyroms_toolbox/nc_create_roms_file.py:51: UserWarning: WARNING: valid_min cannot be safely cast to variable dtype
nc.variables['s_rho'].valid_min = '-1.0'
/home/username/Desktop/own_download_pyroms/pyroms/pyroms_toolbox/pyroms_toolbox/nc_create_roms_file.py:52: UserWarning: WARNING: valid_max cannot be safely cast to variable dtype
nc.variables['s_rho'].valid_max = '0.0'
/home/username/Desktop/own_download_pyroms/pyroms/pyroms_toolbox/pyroms_toolbox/nc_create_roms_file.py:58: UserWarning: WARNING: valid_min cannot be safely cast to variable dtype
nc.variables['s_w'].valid_min = '-1.0'
/home/username/Desktop/own_download_pyroms/pyroms/pyroms_toolbox/pyroms_toolbox/nc_create_roms_file.py:59: UserWarning: WARNING: valid_max cannot be safely cast to variable dtype
nc.variables['s_w'].valid_max = '0.0'
/home/username/Desktop/own_download_pyroms/pyroms/pyroms_toolbox/pyroms_toolbox/nc_create_roms_file.py:65: UserWarning: WARNING: valid_min cannot be safely cast to variable dtype
nc.variables['Cs_r'].valid_min = '-1.0'
/home/username/Desktop/own_download_pyroms/pyroms/pyroms_toolbox/pyroms_toolbox/nc_create_roms_file.py:66: UserWarning: WARNING: valid_max cannot be safely cast to variable dtype
nc.variables['Cs_r'].valid_max = '0.0'
/home/username/Desktop/own_download_pyroms/pyroms/pyroms_toolbox/pyroms_toolbox/nc_create_roms_file.py:72: UserWarning: WARNING: valid_min cannot be safely cast to variable dtype
nc.variables['Cs_w'].valid_min = '-1.0'
/home/username/Desktop/own_download_pyroms/pyroms/pyroms_toolbox/pyroms_toolbox/nc_create_roms_file.py:73: UserWarning: WARNING: valid_max cannot be safely cast to variable dtype
nc.variables['Cs_w'].valid_max = '0.0'
Creating destination file ./Godas_uvsshts_jan_2019__v_clim_GODASROMS.nc
Creating variable u
Traceback (most recent call last):
File "/home/username/anaconda3/envs/pyroms2/lib/python3.8/site-packages/netCDF4/utils.py", line 48, in _find_dim
dim = group.dimensions[dimname]
AttributeError: 'NoneType' object has no attribute 'dimensions'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/username/anaconda3/envs/pyroms2/lib/python3.8/site-packages/netCDF4/utils.py", line 52, in _find_dim
group = group.parent
AttributeError: 'NoneType' object has no attribute 'parent'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "cppmake_clm_file.py", line 66, in <module>
remap_clm_uv(file, src_grd, dst_grd, dst_dir=dst_dir)
File "/home/username/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy/remap_clm_uv.py", line 70, in remap_clm_uv
ncu.createVariable('u', 'f8', ('time', 's_rho', 'eta_u', 'xi_u'), fill_value=spval)
File "netCDF4/_netCDF4.pyx", line 2768, in netCDF4._netCDF4.Dataset.createVariable
File "netCDF4/_netCDF4.pyx", line 3775, in netCDF4._netCDF4.Variable.__init__
File "/home/username/anaconda3/envs/pyroms2/lib/python3.8/site-packages/netCDF4/utils.py", line 54, in _find_dim
raise ValueError("cannot find dimension %s in this group or parent groups" % dimname)
ValueError: cannot find dimension time in this group or parent groups
Any help will be Highly Appreciated. Thank you.
It is failing while creating the "u" variable in the output netcdf file, saying there are no dimensions or 'parent' either. The file gets created on line 41 and that's where the dimensions and the time variable should have been added. The file is then opened for adding to on line 49. It seems like your first step failed (line 41).
It told you the name of the file it is making here: print('\nCreating destination file', dst_fileu). Can you do "ncdump -h [dst_fileu]" on it?
Hi @kshedstrom My Source grid GODAS(Godas_uvsshts_jan2019.nc) u variable ncdump detail
netcdf Godas_uvsshts_jan_2019_ {
dimensions:
xt = 720 ;
bnds = 2 ;
yt = 410 ;
xt_ocean = 720 ;
yt_ocean = 410 ;
xu_ocean = 720 ;
yu_ocean = 410 ;
zt_ocean = 40 ;
time = UNLIMITED ; // (31 currently)
variables:
float xt(xt) ;
xt:standard_name = "longitude" ;
xt:long_name = "longitude" ;
xt:units = "degrees_east" ;
xt:axis = "X" ;
xt:bounds = "xt_bnds" ;
float xt_bnds(xt, bnds) ;
float yt(yt) ;
yt:standard_name = "latitude" ;
yt:long_name = "latitude" ;
yt:units = "degrees_north" ;
yt:axis = "Y" ;
yt:bounds = "yt_bnds" ;
float yt_bnds(yt, bnds) ;
float xt_ocean(xt_ocean) ;
xt_ocean:standard_name = "longitude" ;
xt_ocean:long_name = "tcell longitude" ;
xt_ocean:units = "degrees_east" ;
xt_ocean:axis = "X" ;
float yt_ocean(yt_ocean) ;
yt_ocean:standard_name = "latitude" ;
yt_ocean:long_name = "tcell latitude" ;
yt_ocean:units = "degrees_north" ;
yt_ocean:axis = "Y" ;
float xu_ocean(xu_ocean) ;
xu_ocean:standard_name = "longitude" ;
xu_ocean:long_name = "ucell longitude" ;
xu_ocean:units = "degrees_east" ;
xu_ocean:axis = "X" ;
float yu_ocean(yu_ocean) ;
yu_ocean:standard_name = "latitude" ;
yu_ocean:long_name = "ucell latitude" ;
yu_ocean:units = "degrees_north" ;
yu_ocean:axis = "Y" ;
float zt_ocean(zt_ocean) ;
zt_ocean:standard_name = "depth" ;
zt_ocean:long_name = "tcell depth" ;
zt_ocean:units = "meters" ;
zt_ocean:positive = "down" ;
zt_ocean:axis = "Z" ;
zt_ocean:bounds = "zt_ocean_bnds" ;
float zt_ocean_bnds(zt_ocean, bnds) ;
double time(time) ;
time:standard_name = "time" ;
time:long_name = "time" ;
time:bounds = "time_bnds" ;
time:units = "days since 1901-1-1 00:00:00" ;
time:calendar = "standard" ;
time:axis = "T" ;
double time_bnds(time, bnds) ;
float SSH(time, yt, xt) ;
SSH:long_name = "sea surface height" ;
SSH:units = "m" ;
SSH:_FillValue = -1.e+34f ;
SSH:missing_value = -1.e+34f ;
SSH:history = "From /home/mom/godas/DATA/OUTPUT/OCEAN_RA/OUT/20190101.ice.nc" ;
float temp(time, zt_ocean, yt_ocean, xt_ocean) ;
temp:long_name = "Potential temperature" ;
temp:units = "deg_C" ;
temp:_FillValue = -1.e+10f ;
temp:missing_value = -1.e+10f ;
temp:history = "From /home/mom/godas/IGODAS/DATA/OUT/20190101.ocean_TS.nc" ;
float salt(time, zt_ocean, yt_ocean, xt_ocean) ;
salt:long_name = "Salinity" ;
salt:units = "psu" ;
salt:_FillValue = -1.e+10f ;
salt:missing_value = -1.e+10f ;
salt:history = "From /home/mom/godas/IGODAS/DATA/OUT/20190101.ocean_TS.nc" ;
**float u(time, zt_ocean, yu_ocean, xu_ocean) ;
u:long_name = "zonal current" ;
u:units = "m/sec" ;
u:_FillValue = -10.f ;
u:missing_value = -10.f ;
u:history = "From /home/mom/godas/IGODAS/DATA/OUT/20190101.ocean_UV.nc" ;**
float v(time, zt_ocean, yu_ocean, xu_ocean) ;
v:long_name = "meridional current" ;
v:units = "m/sec" ;
v:_FillValue = -10.f ;
v:missing_value = -10.f ;
v:history = "From /home/mom/godas/IGODAS/DATA/OUT/20190101.ocean_UV.nc" ;
// global attributes:
:CDI = "Climate Data Interface version ?? (http://mpimet.mpg.de/cdi)" ;
:Conventions = "CF-1.6" ;
:history = "Thu Mar 25 13:06:12 2021: cdo merge Jan2019_GODAS_SSH.nc Jan_2019_GODAS_TS.nc Jan_2019_GODAS_UV.nc Godas_uvsshts_jan_2019_.nc\n",
"Mon Feb 22 16:23:21 2021: cdo selmon,1 daymean_2019_OG_UV.nc Jan_2019_GODAS_UV.nc\n",
"Wed Sep 23 14:28:36 2020: cdo shifttime,1sec -daymean -shifttime,-1sec 2019_OG_UV.nc daymean_2019_OG_UV.nc\n",
"FERRET V7.3 23-Sep-20" ;
:frequency = "day" ;
:CDO = "Climate Data Operators version 1.7.0 (http://mpimet.mpg.de/cdo)" ;
And in my Roms Gridid.txt nc file, u variable is not able as it seem below ROMS gridid ncdump
netcdf roms_grd_1x12 {
dimensions:
xi_u = 1080 ;
eta_u = 757 ;
xi_v = 1081 ;
eta_v = 756 ;
xi_rho = 1081 ;
eta_rho = 757 ;
xi_psi = 1080 ;
eta_psi = 756 ;
one = 1 ;
two = 2 ;
four = 4 ;
bath = 1 ;
variables:
double xl(one) ;
xl:long_name = "domain length in the XI-direction" ;
xl:units = "meter" ;
double el(one) ;
el:long_name = "domain length in the ETA-direction" ;
el:units = "meter" ;
double depthmin(one) ;
depthmin:long_name = "Shallow bathymetry clipping depth" ;
depthmin:units = "meter" ;
double depthmax(one) ;
depthmax:long_name = "Deep bathymetry clipping depth" ;
depthmax:units = "meter" ;
char spherical(one) ;
spherical:long_name = "Grid type logical switch" ;
spherical:option_T = "spherical" ;
double angle(eta_rho, xi_rho) ;
angle:long_name = "angle between xi axis and east" ;
angle:units = "degree" ;
double h(eta_rho, xi_rho) ;
h:long_name = "Final bathymetry at RHO-points" ;
h:units = "meter" ;
double hraw(bath, eta_rho, xi_rho) ;
hraw:long_name = "Working bathymetry at RHO-points" ;
hraw:units = "meter" ;
double alpha(eta_rho, xi_rho) ;
alpha:long_name = "Weights between coarse and fine grids at RHO-points" ;
double f(eta_rho, xi_rho) ;
f:long_name = "Coriolis parameter at RHO-points" ;
f:units = "second-1" ;
double pm(eta_rho, xi_rho) ;
pm:long_name = "curvilinear coordinate metric in XI" ;
pm:units = "meter-1" ;
double pn(eta_rho, xi_rho) ;
pn:long_name = "curvilinear coordinate metric in ETA" ;
pn:units = "meter-1" ;
double dndx(eta_rho, xi_rho) ;
dndx:long_name = "xi derivative of inverse metric factor pn" ;
dndx:units = "meter" ;
double dmde(eta_rho, xi_rho) ;
dmde:long_name = "eta derivative of inverse metric factor pm" ;
dmde:units = "meter" ;
double x_rho(eta_rho, xi_rho) ;
x_rho:long_name = "x location of RHO-points" ;
x_rho:units = "meter" ;
double x_u(eta_u, xi_u) ;
x_u:long_name = "x location of U-points" ;
x_u:units = "meter" ;
double x_v(eta_v, xi_v) ;
x_v:long_name = "x location of V-points" ;
x_v:units = "meter" ;
double x_psi(eta_psi, xi_psi) ;
x_psi:long_name = "x location of PSI-points" ;
x_psi:units = "meter" ;
double y_rho(eta_rho, xi_rho) ;
y_rho:long_name = "y location of RHO-points" ;
y_rho:units = "meter" ;
double y_u(eta_u, xi_u) ;
y_u:long_name = "y location of U-points" ;
y_u:units = "meter" ;
double y_v(eta_v, xi_v) ;
y_v:long_name = "y location of V-points" ;
y_v:units = "meter" ;
double y_psi(eta_psi, xi_psi) ;
y_psi:long_name = "y location of PSI-points" ;
y_psi:units = "meter" ;
double lon_rho(eta_rho, xi_rho) ;
lon_rho:long_name = "longitude of RHO-points" ;
lon_rho:units = "degree_east" ;
double lon_u(eta_u, xi_u) ;
lon_u:long_name = "longitude of U-points" ;
lon_u:units = "degree_east" ;
double lon_v(eta_v, xi_v) ;
lon_v:long_name = "longitude of V-points" ;
lon_v:units = "degree_east" ;
double lon_psi(eta_psi, xi_psi) ;
lon_psi:long_name = "longitude of PSI-points" ;
lon_psi:units = "degree_east" ;
double lat_rho(eta_rho, xi_rho) ;
lat_rho:long_name = "latitude of RHO-points" ;
lat_rho:units = "degree_north" ;
double lat_u(eta_u, xi_u) ;
lat_u:long_name = "latitude of U-points" ;
lat_u:units = "degree_north" ;
double lat_v(eta_v, xi_v) ;
lat_v:long_name = "latitude of V-points" ;
lat_v:units = "degree_north" ;
double lat_psi(eta_psi, xi_psi) ;
lat_psi:long_name = "latitude of PSI-points" ;
lat_psi:units = "degree_north" ;
double mask_rho(eta_rho, xi_rho) ;
mask_rho:long_name = "mask on RHO-points" ;
mask_rho:option_0 = "land" ;
mask_rho:option_1 = "water" ;
double mask_u(eta_u, xi_u) ;
mask_u:long_name = "mask on U-points" ;
mask_u:option_0 = "land" ;
mask_u:option_1 = "water" ;
double mask_v(eta_v, xi_v) ;
mask_v:long_name = "mask on V-points" ;
mask_v:option_0 = "land" ;
mask_v:option_1 = "water" ;
double mask_psi(eta_psi, xi_psi) ;
mask_psi:long_name = "mask on PSI-points" ;
mask_psi:option_0 = "land" ;
mask_psi:option_1 = "water" ;
// global attributes:
:title = "NorthWestCoast" ;
:date = "30-Aug-2013" ;
:type = "ROMS grid file" ;
}
Now my destination half created file ncdump Godas_uvsshts_jan_2019__u_clim_GODASROMS.nc
netcdf Godas_uvsshts_jan_2019__u_clim_GODASROMS {
dimensions:
xi_rho = 1081 ;
xi_u = 1080 ;
xi_v = 1081 ;
xi_psi = 1080 ;
eta_rho = 757 ;
eta_u = 757 ;
eta_v = 756 ;
eta_psi = 756 ;
s_rho = 50 ;
s_w = 51 ;
ocean_time = UNLIMITED ; // (0 currently)
variables:
double theta_s ;
theta_s:long_name = "S-coordinate surface control parameter" ;
double theta_b ;
theta_b:long_name = "S-coordinate bottom control parameter" ;
double Tcline ;
Tcline:long_name = "S-cordinate surface/bottom layer width" ;
Tcline:units = "meter" ;
double hc ;
hc:long_name = "S-coordinate parameter, critical depth" ;
hc:units = "meter" ;
double s_rho(s_rho) ;
s_rho:long_name = "S-coordinate at RHO-points" ;
s_rho:valid_min = "-1.0" ;
s_rho:valid_max = "0.0" ;
s_rho:field = "s_rho,scalar" ;
double s_w(s_w) ;
s_w:long_name = "S-coordinate at W-points" ;
s_w:valid_min = "-1.0" ;
s_w:valid_max = "0.0" ;
s_w:field = "s_w,scalar" ;
double Cs_r(s_rho) ;
Cs_r:long_name = "S-coordinate stretching curves at RHO-points" ;
Cs_r:valid_min = "-1.0" ;
Cs_r:valid_max = "0.0" ;
Cs_r:field = "Cs_r,scalar" ;
double Cs_w(s_w) ;
Cs_w:long_name = "S-coordinate stretching curves at W-points" ;
Cs_w:valid_min = "-1.0" ;
Cs_w:valid_max = "0.0" ;
Cs_w:field = "Cs_w,scalar" ;
double h(eta_rho, xi_rho) ;
h:long_name = "bathymetry at RHO-points" ;
h:units = "meter" ;
h:coordinates = "lon_rho lat_rho" ;
h:field = "bath, scalar" ;
double pm(eta_rho, xi_rho) ;
pm:long_name = "curvilinear coordinate metric in XI" ;
pm:units = "meter-1" ;
pm:coordinates = "lon_rho lat_rho" ;
pm:field = "pm, scalar" ;
double pn(eta_rho, xi_rho) ;
pn:long_name = "curvilinear coordinate metric in ETA" ;
pn:units = "meter-1" ;
pn:coordinates = "lon_rho lat_rho" ;
pn:field = "pn, scalar" ;
double lon_rho(eta_rho, xi_rho) ;
lon_rho:long_name = "longitude of RHO-points" ;
lon_rho:units = "degree_east" ;
lon_rho:field = "lon_rho, scalar" ;
double lat_rho(eta_rho, xi_rho) ;
lat_rho:long_name = "latitude of RHO-points" ;
lat_rho:units = "degree_north" ;
lat_rho:field = "lat_rho, scalar" ;
double lon_u(eta_u, xi_u) ;
lon_u:long_name = "longitude of U-points" ;
lon_u:units = "degree_east" ;
lon_u:field = "lon_u, scalar" ;
double lat_u(eta_u, xi_u) ;
lat_u:long_name = "latitude of U-points" ;
lat_u:units = "degree_north" ;
lat_u:field = "lat_u, scalar" ;
double lon_v(eta_v, xi_v) ;
lon_v:long_name = "longitude of V-points" ;
lon_v:units = "degree_east" ;
lon_v:field = "lon_v, scalar" ;
double lat_v(eta_v, xi_v) ;
lat_v:long_name = "latitude of V-points" ;
lat_v:units = "degree_north" ;
lat_v:field = "lat_v, scalar" ;
double lon_psi(eta_psi, xi_psi) ;
lon_psi:long_name = "longitude of PSI-points" ;
lon_psi:units = "degree_east" ;
lon_psi:field = "lon_psi, scalar" ;
double lat_psi(eta_psi, xi_psi) ;
lat_psi:long_name = "latitude of PSI-points" ;
lat_psi:units = "degree_north" ;
lat_psi:field = "lat_psi, scalar" ;
double angle(eta_rho, xi_rho) ;
angle:long_name = "angle between XI-axis and EAST" ;
angle:units = "radians" ;
angle:coordinates = "lon_rho lat_rho" ;
angle:field = "angle, scalar" ;
double mask_rho(eta_rho, xi_rho) ;
mask_rho:long_name = "mask on RHO-points" ;
mask_rho:option_0 = "land" ;
mask_rho:option_1 = "water" ;
mask_rho:coordinates = "lon_rho lat_rho" ;
double mask_u(eta_u, xi_u) ;
mask_u:long_name = "mask on U-points" ;
mask_u:option_0 = "land" ;
mask_u:option_1 = "water" ;
mask_u:coordinates = "lon_u lat_u" ;
double mask_v(eta_v, xi_v) ;
mask_v:long_name = "mask on V-points" ;
mask_v:option_0 = "land" ;
mask_v:option_1 = "water" ;
mask_v:coordinates = "lon_v lat_v" ;
double mask_psi(eta_psi, xi_psi) ;
mask_psi:long_name = "mask on PSI-points" ;
mask_psi:option_0 = "land" ;
mask_psi:option_1 = "water" ;
mask_psi:coordinates = "lon_psi lat_psi" ;
double ocean_time(ocean_time) ;
ocean_time:long_name = "time" ;
ocean_time:units = "days since 1900-01-01 00:00:00" ;
ocean_time:field = " " ;
// global attributes:
:Description = "ROMS file" ;
:Author = "pyroms_toolbox.nc_create_roms_file" ;
:Created = "2021-03-25 18:53:01" ;
:title = "ROMS file" ;
}
Any help will be Highly Appreciated. Thank you.
Your partial file looks fine. I have no idea what the problem is.
Hi, I solved the previous issue. Thank you. but now i am getting some weight file error from xesmf. can you suggest me something regarding solving this error.
type: <class 'xarray.core.dataset.Dataset'>
Traceback (most recent call last):
File "cppmake_clm_file.py", line 66, in <module>
remap_clm_uv(file, src_grd, dst_grd, dst_dir=dst_dir)
File "/home/username/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy/remap_clm_uv.py", line 117, in remap_clm_uv
dst_uz = regrid_GLBy(src_uz, method='nearest_s2d')
File "/home/username/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy/regrid_GLBy.py", line 11, in regrid_GLBy
regrid = xesmf.Regridder(
File "/home/username/anaconda3/envs/pyroms2/lib/python3.8/site-packages/xesmf/frontend.py", line 698, in __init__
super().__init__(grid_in, grid_out, method, input_dims=input_dims, **kwargs)
File "/home/username/anaconda3/envs/pyroms2/lib/python3.8/site-packages/xesmf/frontend.py", line 314, in __init__
self.weights = read_weights(weights, self.n_in, self.n_out)
File "/home/username/anaconda3/envs/pyroms2/lib/python3.8/site-packages/xesmf/smm.py", line 41, in read_weights
raise IOError(f'Weights file not found on disk.\n{weights}')
**OSError: Weights file not found on disk.
regrid_t.nc**
(pyroms2) username@username-Desktop:~/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy$
From where i can get this regrid_t.nc file. Thank you.
I thought it created the regrid_t.nc file the first time it runs, then it can reuse it for later runs with the same remapping. Does it have permission to write in the current directory?
Hi, I think i almost very near to my final result. i think i have to search how to give full permission to write new regid_t.nc to my current directory. Anyway current the my destination remapu is creating and below is detail of new created destination nc file, can you please look into it please , time L coming wrong 1:0
yes? show data
currently SET data sets:
1> ./Godas_uvsshts_jan_2019__u_clim_GODASROMS.nc (default)
name title I J K L
THETA_S S-coordinate surface control pa ... ... ... ...
THETA_B S-coordinate bottom control par ... ... ... ...
TCLINE S-cordinate surface/bottom laye ... ... ... ...
HC S-coordinate parameter, critica ... ... ... ...
CS_R S-coordinate stretching curves ... ... 1:50 ...
CS_W S-coordinate stretching curves 1:51 ... ... ...
H bathymetry at RHO-points 1:1081 1:757 ... ...
PM curvilinear coordinate metric i 1:1081 1:757 ... ...
PN curvilinear coordinate metric i 1:1081 1:757 ... ...
LON_RHO longitude of RHO-points 1:1081 1:757 ... ...
LAT_RHO latitude of RHO-points 1:1081 1:757 ... ...
LON_U longitude of U-points 1:1080 1:757 ... ...
LAT_U latitude of U-points 1:1080 1:757 ... ...
LON_V longitude of V-points 1:1081 1:756 ... ...
LAT_V latitude of V-points 1:1081 1:756 ... ...
LON_PSI longitude of PSI-points 1:1080 1:756 ... ...
LAT_PSI latitude of PSI-points 1:1080 1:756 ... ...
ANGLE angle between XI-axis and EAST 1:1081 1:757 ... ...
MASK_RHO mask on RHO-points 1:1081 1:757 ... ...
MASK_U mask on U-points 1:1080 1:757 ... ...
MASK_V mask on V-points 1:1081 1:756 ... ...
MASK_PSI mask on PSI-points 1:1080 1:756 ... ...
TIME time ... ... ... 1:0
U 3D u-momentum component 1:1080 1:757 1:50 1:0
UBAR 2D u-momentum component 1:1080 1:757 ... 1:0
ncdump -h Godas_uvsshts_jan_2019__u_clim_GODASROMS.nc
netcdf Godas_uvsshts_jan_2019__u_clim_GODASROMS {
dimensions:
xi_rho = 1081 ;
xi_u = 1080 ;
xi_v = 1081 ;
xi_psi = 1080 ;
eta_rho = 757 ;
eta_u = 757 ;
eta_v = 756 ;
eta_psi = 756 ;
s_rho = 50 ;
s_w = 51 ;
time = UNLIMITED ; // (0 currently)
variables:
double theta_s ;
theta_s:long_name = "S-coordinate surface control parameter" ;
double theta_b ;
theta_b:long_name = "S-coordinate bottom control parameter" ;
double Tcline ;
Tcline:long_name = "S-cordinate surface/bottom layer width" ;
Tcline:units = "meter" ;
double hc ;
hc:long_name = "S-coordinate parameter, critical depth" ;
hc:units = "meter" ;
double s_rho(s_rho) ;
s_rho:long_name = "S-coordinate at RHO-points" ;
s_rho:valid_min = "-1.0" ;
s_rho:valid_max = "0.0" ;
s_rho:field = "s_rho,scalar" ;
double s_w(s_w) ;
s_w:long_name = "S-coordinate at W-points" ;
s_w:valid_min = "-1.0" ;
s_w:valid_max = "0.0" ;
s_w:field = "s_w,scalar" ;
double Cs_r(s_rho) ;
Cs_r:long_name = "S-coordinate stretching curves at RHO-points" ;
Cs_r:valid_min = "-1.0" ;
Cs_r:valid_max = "0.0" ;
Cs_r:field = "Cs_r,scalar" ;
double Cs_w(s_w) ;
Cs_w:long_name = "S-coordinate stretching curves at W-points" ;
Cs_w:valid_min = "-1.0" ;
Cs_w:valid_max = "0.0" ;
Cs_w:field = "Cs_w,scalar" ;
double h(eta_rho, xi_rho) ;
h:long_name = "bathymetry at RHO-points" ;
h:units = "meter" ;
h:coordinates = "lon_rho lat_rho" ;
h:field = "bath, scalar" ;
double pm(eta_rho, xi_rho) ;
pm:long_name = "curvilinear coordinate metric in XI" ;
pm:units = "meter-1" ;
pm:coordinates = "lon_rho lat_rho" ;
pm:field = "pm, scalar" ;
double pn(eta_rho, xi_rho) ;
pn:long_name = "curvilinear coordinate metric in ETA" ;
pn:units = "meter-1" ;
pn:coordinates = "lon_rho lat_rho" ;
pn:field = "pn, scalar" ;
double lon_rho(eta_rho, xi_rho) ;
lon_rho:long_name = "longitude of RHO-points" ;
lon_rho:units = "degree_east" ;
lon_rho:field = "lon_rho, scalar" ;
double lat_rho(eta_rho, xi_rho) ;
lat_rho:long_name = "latitude of RHO-points" ;
lat_rho:units = "degree_north" ;
lat_rho:field = "lat_rho, scalar" ;
double lon_u(eta_u, xi_u) ;
lon_u:long_name = "longitude of U-points" ;
lon_u:units = "degree_east" ;
lon_u:field = "lon_u, scalar" ;
double lat_u(eta_u, xi_u) ;
lat_u:long_name = "latitude of U-points" ;
lat_u:units = "degree_north" ;
lat_u:field = "lat_u, scalar" ;
double lon_v(eta_v, xi_v) ;
lon_v:long_name = "longitude of V-points" ;
lon_v:units = "degree_east" ;
lon_v:field = "lon_v, scalar" ;
double lat_v(eta_v, xi_v) ;
lat_v:long_name = "latitude of V-points" ;
lat_v:units = "degree_north" ;
lat_v:field = "lat_v, scalar" ;
double lon_psi(eta_psi, xi_psi) ;
lon_psi:long_name = "longitude of PSI-points" ;
lon_psi:units = "degree_east" ;
lon_psi:field = "lon_psi, scalar" ;
double lat_psi(eta_psi, xi_psi) ;
lat_psi:long_name = "latitude of PSI-points" ;
lat_psi:units = "degree_north" ;
lat_psi:field = "lat_psi, scalar" ;
double angle(eta_rho, xi_rho) ;
angle:long_name = "angle between XI-axis and EAST" ;
angle:units = "radians" ;
angle:coordinates = "lon_rho lat_rho" ;
angle:field = "angle, scalar" ;
double mask_rho(eta_rho, xi_rho) ;
mask_rho:long_name = "mask on RHO-points" ;
mask_rho:option_0 = "land" ;
mask_rho:option_1 = "water" ;
mask_rho:coordinates = "lon_rho lat_rho" ;
double mask_u(eta_u, xi_u) ;
mask_u:long_name = "mask on U-points" ;
mask_u:option_0 = "land" ;
mask_u:option_1 = "water" ;
mask_u:coordinates = "lon_u lat_u" ;
double mask_v(eta_v, xi_v) ;
mask_v:long_name = "mask on V-points" ;
mask_v:option_0 = "land" ;
mask_v:option_1 = "water" ;
mask_v:coordinates = "lon_v lat_v" ;
double mask_psi(eta_psi, xi_psi) ;
mask_psi:long_name = "mask on PSI-points" ;
mask_psi:option_0 = "land" ;
mask_psi:option_1 = "water" ;
mask_psi:coordinates = "lon_psi lat_psi" ;
double time(time) ;
time:long_name = "time" ;
time:units = "days since 1900-01-01 00:00:00" ;
time:field = " " ;
double u(time, s_rho, eta_u, xi_u) ;
u:_FillValue = -10. ;
u:long_name = "3D u-momentum component" ;
u:units = "meter second-1" ;
u:field = "u-velocity, scalar, series" ;
u:time = "time" ;
double ubar(time, eta_u, xi_u) ;
ubar:_FillValue = -10. ;
ubar:long_name = "2D u-momentum component" ;
ubar:units = "meter second-1" ;
ubar:field = "ubar-velocity,, scalar, series" ;
ubar:time = "time" ;
// global attributes:
:Description = "ROMS file" ;
:Author = "pyroms_toolbox.nc_create_roms_file" ;
:Created = "2021-04-01 13:27:23" ;
:title = "ROMS file" ;
}
(pyroms2) username@username-Desktop:~/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy$
Thank you very much.
The file looks great, except it has no records in it. Did you get any errors when running the remapping? I can't tell from this what went wrong.
Hi, This regrid_t.nc error is coming and script is stopping . :( I don't know how to solve this regrid-t.nc file error i think there is some issue with Xesmf module itself /home/username/anaconda3/envs/pyroms2/lib/python3.8/site-packages/xesmf/smm.py
type: <class 'xarray.core.dataset.Dataset'>
Traceback (most recent call last):
File "cppmake_clm_file.py", line 66, in <module>
remap_clm_uv(file, src_grd, dst_grd, dst_dir=dst_dir)
File "/home/username/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy/remap_clm_uv.py", line 117, in remap_clm_uv
dst_uz = regrid_GLBy(src_uz, method='nearest_s2d')
File "/home/username/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy/regrid_GLBy.py", line 11, in regrid_GLBy
regrid = xesmf.Regridder(
File "/home/username/anaconda3/envs/pyroms2/lib/python3.8/site-packages/xesmf/frontend.py", line 698, in __init__
super().__init__(grid_in, grid_out, method, input_dims=input_dims, **kwargs)
File "/home/username/anaconda3/envs/pyroms2/lib/python3.8/site-packages/xesmf/frontend.py", line 314, in __init__
self.weights = read_weights(weights, self.n_in, self.n_out)
File "/home/username/anaconda3/envs/pyroms2/lib/python3.8/site-packages/xesmf/smm.py", line 41, in read_weights
raise IOError(f'Weights file not found on disk.\n{weights}')
**OSError: Weights file not found on disk.
regrid_t.nc**
(pyroms2) username@username-Desktop:~/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy$
Hi @kshedstrom please let me know how to solve this regrid_t.nc, I am stuck at this point. I opened /home/username/anaconda3/envs/pyroms2/lib/python3.8/site-packages/xesmf/smm.py not able to get it. Kindly let me know to generate regrid_t.nc file I am all most at the end of this. Any help will be Highly Appreciated. Thank you.
Your username is username? Do you not have permission to open that file? I can open it on my system - it's a sparse matrix multiply. It must be failing before that, at the step where it generates the sparse matrix. I'm afraid I have no idea how to help.
HI @kshedstrom , Can you help me to know why we are doing renaming of variable in below line?
import xarray as xr
import xesmf
def regrid_GLBy(fld, method='nearest_s2d'):
coords = xr.open_dataset('/home/msa/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy/roms_grd_1x12.nc')
**coords = coords.rename({'lon_rho': 'lon', 'lat_rho': 'lat'})**
gsource = xr.open_dataset('/home/msa/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy/Godas_uvsshts_jan_2019_.nc')
regrid = xesmf.Regridder(
gsource,
coords,
method=method,
periodic=False,
filename='regrid_t.nc',
reuse_weights=True
)
tdest = regrid(fld)
return tdest
I am getting below Error :
KeyError: "Receive multiple variables for key 'longitude': ['xu_ocean', 'xt', 'xt_ocean']. Expected only one. Please pass a list ['longitude'] instead to get all variables matching 'longitude'."
Actually in my GODAS datafile i am having three dimension xu_ocean for parameter1, xt for parameter2 & xt_ocean for parameter3 . i.e 3 different lon value in my one GODAS datafile.
I tried to rename the dimensions and variables of GODAS datafile xu_ocean', 'xt', 'xt_ocean' to 'lon' but then i got ValueError: Cannot rename xt_ocean to lon because lon already exists. Try using swap_dims instead.
as xt_ocean lonigutde range is different from xt longitude range & different from xu_ocean but all xu_ocean , xt and xt_ocean has longitude values only.
And since i am first time generating ic so i sud make reuse_weights=False , Right ? Thank you.
It should be smart enough to create regrid_t.nc if it doesn't exist. Have you tried it both ways?
Yes, you need to rename the longitude variable you are using to lon, but you should only be using one. The ROMS grid has lon_u, lon_psi, lon_v, lon_rho, but we only rename lon_rho. We are remapping temperature, say, onto rho points. The same would be true of the GODAS grid.
Hi, yes I tried both way , reuse_weights=True / False both way but not able to create regrid_t.nc Coming to renaming the dimension and variables, My GODAS grid has 3 different lon grid(xt,xt_ocean,xu_ocean) and 3 different lat grid (yt,yt_ocean,yu_ocean) .
My Source grid GODAS(Godas_uvsshts_jan_2019_.nc) u variable ncdump detail
netcdf Godas_uvsshts_jan_2019_ {
dimensions:
xt = 720 ;
bnds = 2 ;
yt = 410 ;
xt_ocean = 720 ;
yt_ocean = 410 ;
xu_ocean = 720 ;
yu_ocean = 410 ;
zt_ocean = 40 ;
time = UNLIMITED ; // (31 currently)
variables:
float xt(xt) ;
xt:standard_name = "longitude" ;
xt:long_name = "longitude" ;
xt:units = "degrees_east" ;
xt:axis = "X" ;
xt:bounds = "xt_bnds" ;
float xt_bnds(xt, bnds) ;
float yt(yt) ;
yt:standard_name = "latitude" ;
yt:long_name = "latitude" ;
yt:units = "degrees_north" ;
yt:axis = "Y" ;
yt:bounds = "yt_bnds" ;
float yt_bnds(yt, bnds) ;
float xt_ocean(xt_ocean) ;
xt_ocean:standard_name = "longitude" ;
xt_ocean:long_name = "tcell longitude" ;
xt_ocean:units = "degrees_east" ;
xt_ocean:axis = "X" ;
float yt_ocean(yt_ocean) ;
yt_ocean:standard_name = "latitude" ;
yt_ocean:long_name = "tcell latitude" ;
yt_ocean:units = "degrees_north" ;
yt_ocean:axis = "Y" ;
float xu_ocean(xu_ocean) ;
xu_ocean:standard_name = "longitude" ;
xu_ocean:long_name = "ucell longitude" ;
xu_ocean:units = "degrees_east" ;
xu_ocean:axis = "X" ;
float yu_ocean(yu_ocean) ;
yu_ocean:standard_name = "latitude" ;
yu_ocean:long_name = "ucell latitude" ;
yu_ocean:units = "degrees_north" ;
yu_ocean:axis = "Y" ;
float zt_ocean(zt_ocean) ;
zt_ocean:standard_name = "depth" ;
zt_ocean:long_name = "tcell depth" ;
zt_ocean:units = "meters" ;
zt_ocean:positive = "down" ;
zt_ocean:axis = "Z" ;
zt_ocean:bounds = "zt_ocean_bnds" ;
float zt_ocean_bnds(zt_ocean, bnds) ;
double time(time) ;
time:standard_name = "time" ;
time:long_name = "time" ;
time:bounds = "time_bnds" ;
time:units = "days since 1901-1-1 00:00:00" ;
time:calendar = "standard" ;
time:axis = "T" ;
double time_bnds(time, bnds) ;
float SSH(time, yt, xt) ;
SSH:long_name = "sea surface height" ;
SSH:units = "m" ;
SSH:_FillValue = -1.e+34f ;
SSH:missing_value = -1.e+34f ;
SSH:history = "From /home/mom/godas/DATA/OUTPUT/OCEAN_RA/OUT/20190101.ice.nc" ;
float temp(time, zt_ocean, yt_ocean, xt_ocean) ;
temp:long_name = "Potential temperature" ;
temp:units = "deg_C" ;
temp:_FillValue = -1.e+10f ;
temp:missing_value = -1.e+10f ;
temp:history = "From /home/mom/godas/IGODAS/DATA/OUT/20190101.ocean_TS.nc" ;
float salt(time, zt_ocean, yt_ocean, xt_ocean) ;
salt:long_name = "Salinity" ;
salt:units = "psu" ;
salt:_FillValue = -1.e+10f ;
salt:missing_value = -1.e+10f ;
salt:history = "From /home/mom/godas/IGODAS/DATA/OUT/20190101.ocean_TS.nc" ;
**float u(time, zt_ocean, yu_ocean, xu_ocean) ;
u:long_name = "zonal current" ;
u:units = "m/sec" ;
u:_FillValue = -10.f ;
u:missing_value = -10.f ;
u:history = "From /home/mom/godas/IGODAS/DATA/OUT/20190101.ocean_UV.nc" ;**
float v(time, zt_ocean, yu_ocean, xu_ocean) ;
v:long_name = "meridional current" ;
v:units = "m/sec" ;
v:_FillValue = -10.f ;
v:missing_value = -10.f ;
v:history = "From /home/mom/godas/IGODAS/DATA/OUT/20190101.ocean_UV.nc" ;
// global attributes:
:CDI = "Climate Data Interface version ?? (http://mpimet.mpg.de/cdi)" ;
:Conventions = "CF-1.6" ;
:history = "Thu Mar 25 13:06:12 2021: cdo merge Jan2019_GODAS_SSH.nc Jan_2019_GODAS_TS.nc Jan_2019_GODAS_UV.nc Godas_uvsshts_jan_2019_.nc\n",
"Mon Feb 22 16:23:21 2021: cdo selmon,1 daymean_2019_OG_UV.nc Jan_2019_GODAS_UV.nc\n",
"Wed Sep 23 14:28:36 2020: cdo shifttime,1sec -daymean -shifttime,-1sec 2019_OG_UV.nc daymean_2019_OG_UV.nc\n",
"FERRET V7.3 23-Sep-20" ;
:frequency = "day" ;
:CDO = "Climate Data Operators version 1.7.0 (http://mpimet.mpg.de/cdo)" ;
below ROMS gridid ncdump
netcdf roms_grd_1x12 {
dimensions:
xi_u = 1080 ;
eta_u = 757 ;
xi_v = 1081 ;
eta_v = 756 ;
xi_rho = 1081 ;
eta_rho = 757 ;
xi_psi = 1080 ;
eta_psi = 756 ;
one = 1 ;
two = 2 ;
four = 4 ;
bath = 1 ;
variables:
double xl(one) ;
xl:long_name = "domain length in the XI-direction" ;
xl:units = "meter" ;
double el(one) ;
el:long_name = "domain length in the ETA-direction" ;
el:units = "meter" ;
double depthmin(one) ;
depthmin:long_name = "Shallow bathymetry clipping depth" ;
depthmin:units = "meter" ;
double depthmax(one) ;
depthmax:long_name = "Deep bathymetry clipping depth" ;
depthmax:units = "meter" ;
char spherical(one) ;
spherical:long_name = "Grid type logical switch" ;
spherical:option_T = "spherical" ;
double angle(eta_rho, xi_rho) ;
angle:long_name = "angle between xi axis and east" ;
angle:units = "degree" ;
double h(eta_rho, xi_rho) ;
h:long_name = "Final bathymetry at RHO-points" ;
h:units = "meter" ;
double hraw(bath, eta_rho, xi_rho) ;
hraw:long_name = "Working bathymetry at RHO-points" ;
hraw:units = "meter" ;
double alpha(eta_rho, xi_rho) ;
alpha:long_name = "Weights between coarse and fine grids at RHO-points" ;
double f(eta_rho, xi_rho) ;
f:long_name = "Coriolis parameter at RHO-points" ;
f:units = "second-1" ;
double pm(eta_rho, xi_rho) ;
pm:long_name = "curvilinear coordinate metric in XI" ;
pm:units = "meter-1" ;
double pn(eta_rho, xi_rho) ;
pn:long_name = "curvilinear coordinate metric in ETA" ;
pn:units = "meter-1" ;
double dndx(eta_rho, xi_rho) ;
dndx:long_name = "xi derivative of inverse metric factor pn" ;
dndx:units = "meter" ;
double dmde(eta_rho, xi_rho) ;
dmde:long_name = "eta derivative of inverse metric factor pm" ;
dmde:units = "meter" ;
double x_rho(eta_rho, xi_rho) ;
x_rho:long_name = "x location of RHO-points" ;
x_rho:units = "meter" ;
double x_u(eta_u, xi_u) ;
x_u:long_name = "x location of U-points" ;
x_u:units = "meter" ;
double x_v(eta_v, xi_v) ;
x_v:long_name = "x location of V-points" ;
x_v:units = "meter" ;
double x_psi(eta_psi, xi_psi) ;
x_psi:long_name = "x location of PSI-points" ;
x_psi:units = "meter" ;
double y_rho(eta_rho, xi_rho) ;
y_rho:long_name = "y location of RHO-points" ;
y_rho:units = "meter" ;
double y_u(eta_u, xi_u) ;
y_u:long_name = "y location of U-points" ;
y_u:units = "meter" ;
double y_v(eta_v, xi_v) ;
y_v:long_name = "y location of V-points" ;
y_v:units = "meter" ;
double y_psi(eta_psi, xi_psi) ;
y_psi:long_name = "y location of PSI-points" ;
y_psi:units = "meter" ;
double lon_rho(eta_rho, xi_rho) ;
lon_rho:long_name = "longitude of RHO-points" ;
lon_rho:units = "degree_east" ;
double lon_u(eta_u, xi_u) ;
lon_u:long_name = "longitude of U-points" ;
lon_u:units = "degree_east" ;
double lon_v(eta_v, xi_v) ;
lon_v:long_name = "longitude of V-points" ;
lon_v:units = "degree_east" ;
double lon_psi(eta_psi, xi_psi) ;
lon_psi:long_name = "longitude of PSI-points" ;
lon_psi:units = "degree_east" ;
double lat_rho(eta_rho, xi_rho) ;
lat_rho:long_name = "latitude of RHO-points" ;
lat_rho:units = "degree_north" ;
double lat_u(eta_u, xi_u) ;
lat_u:long_name = "latitude of U-points" ;
lat_u:units = "degree_north" ;
double lat_v(eta_v, xi_v) ;
lat_v:long_name = "latitude of V-points" ;
lat_v:units = "degree_north" ;
double lat_psi(eta_psi, xi_psi) ;
lat_psi:long_name = "latitude of PSI-points" ;
lat_psi:units = "degree_north" ;
double mask_rho(eta_rho, xi_rho) ;
mask_rho:long_name = "mask on RHO-points" ;
mask_rho:option_0 = "land" ;
mask_rho:option_1 = "water" ;
double mask_u(eta_u, xi_u) ;
mask_u:long_name = "mask on U-points" ;
mask_u:option_0 = "land" ;
mask_u:option_1 = "water" ;
double mask_v(eta_v, xi_v) ;
mask_v:long_name = "mask on V-points" ;
mask_v:option_0 = "land" ;
mask_v:option_1 = "water" ;
double mask_psi(eta_psi, xi_psi) ;
mask_psi:long_name = "mask on PSI-points" ;
mask_psi:option_0 = "land" ;
mask_psi:option_1 = "water" ;
// global attributes:
:title = "NorthWestCoast" ;
:date = "30-Aug-2013" ;
:type = "ROMS grid file" ;
}
Can you suggest me which all dimensions and variables to rename to lat , lon of ROMS for salt parameter( as example). Thank you.
float salt(time, zt_ocean, yt_ocean, xt_ocean) ;
I would rename yt_ocean and xt_ocean to lat and lon on the GODAS side. For ROMS, it would be lat_rho and lon_rho. For GODAS, I assume it is on an Arakawa B-grid. Is that true? Are xt and xt_ocean the same?
yes, xt and xt_ocean are same but xu_ocean is different as i can see below:
1> ./Godas_uvsshts_jan_2019_.nc (default)
name title I J K L
SSH sea surface height 1:720 1:410 ... 1:31
TEMP Potential temperature 1:720 1:410 1:40 1:31
SALT Salinity 1:720 1:410 1:40 1:31
U zonal current 1:720 1:410 1:40 1:31
V meridional current 1:720 1:410 1:40 1:31
yes? list/i=1/j=1/k=1/l=1 salt
VARIABLE : Salinity (psu)
FILENAME : Godas_uvsshts_jan_2019_.nc
LONGITUDE: 80.2E(-279.8)
LATITUDE : 80.8S
DEPTH (m): 5
TIME : 31-DEC-2018 12:00
....
yes? list/i=1/j=1/k=1/l=1 u
VARIABLE : zonal current (m/sec)
FILENAME : Godas_uvsshts_jan_2019_.nc
LONGITUDE: 80.5E(-279.5)
LATITUDE : 80.5S
DEPTH (m): 5
TIME : 31-DEC-2018 12:00
....
yes? list/i=1/j=1/k=1/l=1 ssh
VARIABLE : sea surface height (m)
FILENAME : Godas_uvsshts_jan_2019_.nc
LONGITUDE: 80.2E(-279.8)
LATITUDE : 80.8S
TIME : 31-DEC-2018 12:00
....
yes? list/i=720/j=1/k=1/l=1 ssh
VARIABLE : sea surface height (m)
FILENAME : Godas_uvsshts_jan_2019_.nc
LONGITUDE: 79.8E(79.8)
LATITUDE : 80.8S
TIME : 31-DEC-2018 12:00
....
yes? list/i=720/j=1/k=1/l=1 salt
VARIABLE : Salinity (psu)
FILENAME : Godas_uvsshts_jan_2019_.nc
LONGITUDE: 79.8E
LATITUDE : 80.8S
DEPTH (m): 5
TIME : 31-DEC-2018 12:00
....
ncdump GODAS with variable only below.
float SSH(time, yt, xt) ;
SSH:long_name = "sea surface height" ;
SSH:units = "m" ;
SSH:_FillValue = -1.e+34f ;
SSH:missing_value = -1.e+34f ;
SSH:history = "From /home/mom/godas/DATA/OUTPUT/OCEAN_RA/OUT/20190101.ice.nc" ;
float temp(time, zt_ocean, yt_ocean, xt_ocean) ;
temp:long_name = "Potential temperature" ;
temp:units = "deg_C" ;
temp:_FillValue = -1.e+10f ;
temp:missing_value = -1.e+10f ;
temp:history = "From /home/mom/godas/IGODAS/DATA/OUT/20190101.ocean_TS.nc" ;
float salt(time, zt_ocean, yt_ocean, xt_ocean) ;
salt:long_name = "Salinity" ;
salt:units = "psu" ;
salt:_FillValue = -1.e+10f ;
salt:missing_value = -1.e+10f ;
salt:history = "From /home/mom/godas/IGODAS/DATA/OUT/20190101.ocean_TS.nc" ;
float u(time, zt_ocean, yu_ocean, xu_ocean) ;
u:long_name = "zonal current" ;
u:units = "m/sec" ;
u:_FillValue = -10.f ;
u:missing_value = -10.f ;
u:history = "From /home/mom/godas/IGODAS/DATA/OUT/20190101.ocean_UV.nc" ;
float v(time, zt_ocean, yu_ocean, xu_ocean) ;
v:long_name = "meridional current" ;
v:units = "m/sec" ;
v:_FillValue = -10.f ;
v:missing_value = -10.f ;
v:history = "From /home/mom/godas/IGODAS/DATA/OUT/20190101.ocean_UV.nc" ;
I have installed as per suggested and my installation was successful as well. Kindly let me know how to solve this error. I will really appreciate this help. Thank you.