ESMG/pyroms

Importing ERROR while pyroms & pyroms_toolbox

sameerCoder opened this issue · 66 comments

import pyroms
Traceback (most recent call last):
File "", line 1, in
File "/home/user/python_learn_newfolder/pyroms/pyroms/pyroms/init.py", line 14, in
from . import hgrid
File "/home/user/python_learn_newfolder/pyroms/pyroms/pyroms/hgrid.py", line 22, in
from mpl_toolkits.basemap import Basemap
File "/home/user/anaconda3/envs/pyroms1/lib/python3.8/site-packages/mpl_toolkits/basemap/init.py", line 26, in
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)
import pyroms_toolbox
Traceback (most recent call last):
File "", line 1, in
File "/home/user/python_learn_newfolder/pyroms/pyroms_toolbox/pyroms_toolbox/init.py", line 12, in
from .iview import iview
File "/home/user/python_learn_newfolder/pyroms/pyroms_toolbox/pyroms_toolbox/iview.py", line 4, in
from mpl_toolkits.basemap import Basemap
File "/home/user/anaconda3/envs/pyroms1/lib/python3.8/site-packages/mpl_toolkits/basemap/init.py", line 26, in
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)

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.

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
`

#Error getting.

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 matplotlib/basemap#494?

fredc commented

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.

  1. The hgrid module currently uses Basemap. Fred is saying that (for him) it would be straightforward to modify hgrid to use cartopy instead.
  2. Assuming hgrid could be gotten into a working state, you might not be out of the woods. For me, hgrid is working but scrip is not. Scrip is the compiled fortran code for doing the remapping. It should be replaced with xESMF. I took a stab at that for the new HYCOM.
  3. The examples I provide are for remapping from SODA, old HYCOM, new HYCOM. I don't have any experience with GEODAS. You might have to do some fussing to get what we have to work for 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
from remap import remap
File "/home/username/Desktop/pyroms/examples/Yellow_Sea/Inputs/Initial/remap.py", line 14, in
import _remapping
ModuleNotFoundError: No module named '_remapping'

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_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)" ;


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 detail below

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" ;

yup after changing lon_rho/lat_rho : lon/lat in roms file & xt_ocean/yt_ocean : lon /lat Progress happened but now the index Error as
File "/home/sakib/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy/remap_clm.py", line 138, in remap_clm
print('before vertical remap 1', dst_varz[:,928,324])
IndexError: index 928 is out of bounds for axis 1 with size 757

You've got choices - comment out those print statements or print out a point within your grid.

Hi @kshedstrom,
Hope you are very well.
Here in INDIA situation is very bad due to COVID19. Soon the things will be good in INDIA.
Coming to generation of Initial Condition and Boundary Condition.
Initial condition Generation is excellent . Many Many Thank you for this.
but Boundary Condition I am not getting the values which is required.
Such as -
1- Boundary Condition values are correct but it's indexing system is wrong . showing the data in j index value instead of k.
2- Boundary Condition only showing one time stamp instead of 30 days timestamps(whole one month i am running).

#MY Boundary Condition making code :


import matplotlib
matplotlib.use('Agg')

import subprocess
import os
import sys
import numpy as np
from multiprocessing import Pool
#import pdb

#increase the maximum number of open files allowed
#import resource
#resource.setrlimit(resource.RLIMIT_NOFILE, (3000,-1))

import pyroms
import pyroms_toolbox

from remap_bdry import remap_bdry
from remap_bdry_uv import remap_bdry_uv

lst_year = sys.argv[1:]
print("lst_year:",lst_year)
data_dir = '/home/msa/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy/'
dst_dir='/home/msa/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy/bdry/'

lst_file = []
for year in lst_year:
    lst = subprocess.getoutput('ls ' + data_dir + 'Godas_uvsshts_jan_' + year + '_.nc')
#   lst = subprocess.getoutput('ls ' + data_dir + 'HYCOM_GLBy0.08_' + year + '*')
#    lst = subprocess.getoutput('ls ' + data_dir + 'HYCOM_GLBy0.08_' + year + '_0*')
#    lst = subprocess.getoutput('ls ' + data_dir + 'HYCOM_GLBy0.08_' + year + '_0[4-9]*')
    lst = lst.split()
    lst_file = lst_file + lst

print('Build OBC file from the following file list:')
print(lst_file)
print(' ')

src_grd_file = data_dir  +'Godas_uvsshts_jan_2019_.nc'
src_grd = pyroms_toolbox.Grid_HYCOM.get_nc_Grid_HYCOM2(src_grd_file)
dst_grd = pyroms.grid.get_ROMS_grid('GODASROMS')
def do_file(file):
    zeta = remap_bdry(file, 'SSH', src_grd, dst_grd, dst_dir=dst_dir)
    dst_grd2 = pyroms.grid.get_ROMS_grid('GODASROMS', zeta=zeta)
    remap_bdry(file, 'temp', src_grd, dst_grd2, dst_dir=dst_dir)
    remap_bdry(file, 'salt', src_grd, dst_grd2, dst_dir=dst_dir)
#   pdb.set_trace()
    remap_bdry_uv(file, src_grd, dst_grd2, dst_dir=dst_dir)

    # merge file
    bdry_file = dst_dir + file.rsplit('/')[-1][:-3] + '_bdry_' + dst_grd.name + '.nc'

    out_file = dst_dir + file.rsplit('/')[-1][:-3] + '_SSH_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-O', out_file, bdry_file)
    subprocess.check_call(command)
    os.remove(out_file)
    out_file = dst_dir + file.rsplit('/')[-1][:-3] + '_temp_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-A', out_file, bdry_file)
    subprocess.check_call(command)
    os.remove(out_file)
    out_file = dst_dir + file.rsplit('/')[-1][:-3] + '_salt_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-A', out_file, bdry_file)
    subprocess.check_call(command)
    os.remove(out_file)
    out_file = dst_dir + file.rsplit('/')[-1][:-3] + '_u_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-A', out_file, bdry_file)
    subprocess.check_call(command)
    os.remove(out_file)
    out_file = dst_dir + file.rsplit('/')[-1][:-3] + '_v_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-A', out_file, bdry_file)
    subprocess.check_call(command)
    os.remove(out_file)

processes = 4
p = Pool(processes)
results = p.map(do_file, lst_file)

I am not getting Any Error.
ncdump -h Godas_uvsshts_jan_2019_.nc
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)

Can you please guide me why only one timestamp i am getting even i have 30 timestamp in my source godas data?
I will really Appreciate you.

Thank you.

My Boundary condition show data
image
I think my file should be k=1:40 and L-index will be L=1:31(for jan month)
let me know where i am making mistake
Any Help will be Appreciable.
Thank you
.

I've heard things are bad in India, sorry about that. Things are also not great in Fairbanks, with the hospital full of angry, younger, unvaccinated people - when vaccines are available for all. People are acting unwisely in bars and some churches.

When I was making boundary files from HYCOM, the HYCOM variables are in one file per day. I loop over all the files and then concatenate the outputs into one file. If all your records are in one file, you have to loop over all the times in that file. The file you show is going to run on four processes and it wants to split it up by files - you'll have to rewrite that logic. The easy thing is to make it serial, strip out the multiprocessing.

The boundary file should look something like:

netcdf HYCOM_GLBy_2019_bdry {
dimensions:
	s_rho = 50 ;
	s_w = 51 ;
	eta_rho = 1090 ;
	xi_rho = 690 ;
	ocean_time = UNLIMITED ; // (349 currently)
	eta_u = 1090 ;
	xi_u = 689 ;
	eta_v = 1089 ;
	xi_v = 690 ;
	eta_psi = 1089 ;
	xi_psi = 689 ;
variables:
	double theta_s ;
		theta_s:long_name = "S-coordinate surface control parameter" ;
     :
	double ocean_time(ocean_time) ;
		ocean_time:long_name = "time" ;
		ocean_time:units = "days since 1900-01-01 00:00:00" ;
		ocean_time:field = " " ;
	double zeta_north(ocean_time, xi_rho) ;
		zeta_north:_FillValue = -30000. ;
		zeta_north:long_name = "free-surface north boundary condition" ;
		zeta_north:units = "meter" ;
		zeta_north:field = "zeta_north, scalar, series" ;
    :
	double temp_north(ocean_time, s_rho, xi_rho) ;
		temp_north:_FillValue = -30000. ;
		temp_north:long_name = "potential temperature north boundary condition" ;
		temp_north:units = "Celsius" ;
		temp_north:field = "temp_north, scalar, series" ;
	double temp_south(ocean_time, s_rho, xi_rho) ;
		temp_south:_FillValue = -30000. ;
		temp_south:long_name = "potential temperature south boundary condition" ;
		temp_south:units = "Celsius" ;
		temp_south:field = "temp_south, scalar, series" ;
	double temp_east(ocean_time, s_rho, eta_rho) ;
		temp_east:_FillValue = -30000. ;
		temp_east:long_name = "potential temperature east boundary condition" ;
		temp_east:units = "Celsius" ;
		temp_east:field = "temp_east, scalar, series" ;
	double temp_west(ocean_time, s_rho, eta_rho) ;
		temp_west:_FillValue = -30000. ;
		temp_west:long_name = "potential temperature west boundary condition" ;
		temp_west:units = "Celsius" ;
		temp_west:field = "temp_west, scalar, series" ;

Example of looping over records:

time = root.variables['ocean_time'][:]
for t in range(len(time)):
      <do something with record[t]>

Hi ,
Take care @kshedstrom
This Covid19 is really very dangerous. Even after having negative Report still virus has bad impact on body.
Take care alot. Be safe Be bold.

Coming to creation of boundary condition I am getting Error after changing the remap_bdry.py
when second iteration of time loop in remap_bdry.py i am getting Error.
Error coming is : -

write data in destination file
time bhai: 1
Traceback (most recent call last):
  File "mkebdry.py", line 64, in <module>
    zeta = remap_bdry(file1, 'SSH', src_grd, dst_grd, dst_dir=dst_dir)
  File "/home/msa/Desktop/own_download_pyroms/pyroms/examples/Arctic_HYCOM_GLBy/remap_bdry.py", line 51, in remap_bdry
    spval = src_var._FillValue
AttributeError: 'MaskedArray' object has no attribute '_FillValue'

As suggested i made by make_bdry.py file as single process file.
My make_bdry.py
just creating only zeta ssh parameter, rest parameters i commented.

import os

#file1=input("Enter the Godas full filename:")
file1=("Godas_uvsshts_jan_2019_.nc")
print("Build OBC file from the following file {}.".format(file1))
#directory=input("Enter Absolute Godas file path(Directory path):")
print("os getcwd:",os.getcwd())
directory=os.getcwd()
dst_dir=directory
src_grd=pyroms_toolbox.Grid_HYCOM.get_nc_Grid_HYCOM2(directory+"/"+file1)
dst_grd=pyroms.grid.get_ROMS_grid('GODASROMS')
print("Source grid:",src_grd)
#def do_file(file):
zeta = remap_bdry(file1, 'SSH', src_grd, dst_grd, dst_dir=dst_dir)
dst_grd2 = pyroms.grid.get_ROMS_grid('GODASROMS', zeta=zeta)
#remap_bdry(file1, 'temp', src_grd, dst_grd2, dst_dir=dst_dir)
#remap_bdry(file1, 'salt', src_grd, dst_grd2, dst_dir=dst_dir)
#   pdb.set_trace()
#msa comment remap_bdry_uv(file1, src_grd, dst_grd2, dst_dir=dst_dir)
print("#"*45)
    # merge file
bdry_file = dst_dir + file1.rsplit('/')[-1][:-3] + '_bdry_' + dst_grd.name + '.nc'

out_file = dst_dir + file1.rsplit('/')[-1][:-3] + '_SSH_bdry_' + dst_grd.name + '.nc'
command = ('ncks', '-a', '-O', out_file, bdry_file)
subprocess.check_call(command)
os.remove(out_file)
#out_file = dst_dir + file1.rsplit('/')[-1][:-3] + '_temp_bdry_' + dst_grd.name + '.nc'
#command = ('ncks', '-a', '-A', out_file, bdry_file)
#subprocess.check_call(command)
#os.remove(out_file)
#out_file = dst_dir + file1.rsplit('/')[-1][:-3] + '_salt_bdry_' + dst_grd.name + '.nc'
#command = ('ncks', '-a', '-A', out_file, bdry_file)
#subprocess.check_call(command)
#os.remove(out_file)
#out_file = dst_dir + file1.rsplit('/')[-1][:-3] + '_u_bdry_' + dst_grd.name + '.nc'
#command = ('ncks', '-a', '-A', out_file, bdry_file)
#subprocess.check_call(command)
#os.remove(out_file)
#out_file = dst_dir + file1.rsplit('/')[-1][:-3] + '_v_bdry_' + dst_grd.name + '.nc'
#command = ('ncks', '-a', '-A', out_file, bdry_file)
#subprocess.check_call(command)
#os.remove(out_file)
print("current working directory:",os.getcwd())
print("All task done !!!")

Above make_bdry.py is correct isn't it ?

######################################
#coming to add more timestamp into my final nc file.
I edited remap_bdry.py as below

class nctime(object):
    pass

def remap_bdry(src_file, src_varname, src_grd, dst_grd, dxy=20, cdepth=0, kk=2, dst_dir='./'):

    print(src_file)

    # get time
    nctime.long_name = 'time'
    nctime.units = 'days since 1900-01-01 00:00:00'

    # create boundary file
    dst_file = src_file.rsplit('/')[-1]
    dst_file = dst_dir + dst_file[:-3] + '_' + src_varname + '_bdry_' + dst_grd.name + '.nc'
    print('\nCreating boundary file', dst_file)
    if os.path.exists(dst_file) is True:
        os.remove(dst_file)
    pyroms_toolbox.nc_create_roms_bdry_file(dst_file, dst_grd, nctime)
    # open boundary file
    nc = netCDF.Dataset(dst_file, 'a', format='NETCDF3_64BIT')
    #load var
    cdf = netCDF.Dataset(src_file)
    src_var = cdf.variables[src_varname]
    #msa COMMENTED THIS LINE --------time = cdf.variables['time'][0]
    **time=cdf.variables['time'][:]
    print("time:",time)
    for t in range(len(time)):
        print("time bhai:",t)**
        #get missing value
        spval = src_var._FillValue
        src_var = cdf.variables[src_varname][t]
        # determine variable dimension
        ndim = len(src_var.shape)
        if src_varname == 'SSH':
            pos = 't'
            Cpos = 'rho'
            z = src_grd.z_t
            Mp, Lp = dst_grd.hgrid.mask_rho.shape
            dst_varname = 'zeta'
            dimensions = ('time', 'eta_rho', 'xi_rho')
            long_name = 'free-surface'
            dst_varname_north = 'zeta_north'
            dimensions_north = ('time', 'xi_rho')
            long_name_north = 'free-surface north boundary condition'
            field_north = 'zeta_north, scalar, series'
            dst_varname_south = 'zeta_south'
            dimensions_south = ('time', 'xi_rho')
            long_name_south = 'free-surface south boundary condition'
            field_south = 'zeta_south, scalar, series'
            dst_varname_east = 'zeta_east'
            dimensions_east = ('time', 'eta_rho')
            long_name_east = 'free-surface east boundary condition'
            field_east = 'zeta_east, scalar, series'
            dst_varname_west = 'zeta_west'
            dimensions_west = ('time', 'eta_rho')
            long_name_west = 'free-surface west boundary condition'
            field_west = 'zeta_west, scalar, series'
            units = 'meter'
        elif src_varname == 'temp':
            pos = 't'
            Cpos = 'rho'
            z = src_grd.z_t
            Mp, Lp = dst_grd.hgrid.mask_rho.shape
            dst_varname = 'temperature'
            dst_varname_north = 'temp_north'
            dimensions_north = ('time', 's_rho', 'xi_rho')
            long_name_north = 'potential temperature north boundary condition'
            field_north = 'temp_north, scalar, series'
            dst_varname_south = 'temp_south'
            dimensions_south = ('time', 's_rho', 'xi_rho')
            long_name_south = 'potential temperature south boundary condition'
            field_south = 'temp_south, scalar, series'
            dst_varname_east = 'temp_east'
            dimensions_east = ('time', 's_rho', 'eta_rho')
            long_name_east = 'potential temperature east boundary condition'
            field_east = 'temp_east, scalar, series'
            dst_varname_west = 'temp_west'
            dimensions_west = ('time', 's_rho', 'eta_rho')
            long_name_west = 'potential temperature west boundary condition'
            field_west = 'temp_west, scalar, series'
            units = 'Celsius'
        elif src_varname == 'salt':
            pos = 't'
            Cpos = 'rho'
            z = src_grd.z_t
            Mp, Lp = dst_grd.hgrid.mask_rho.shape
            dst_varname = 'salinity'
            dst_varname_north = 'salt_north'
           dimensions_north = ('time', 's_rho', 'xi_rho')
            long_name_north = 'salinity north boundary condition'
            field_north = 'salt_north, scalar, series'
            dst_varname_south = 'salt_south'
            dimensions_south = ('time', 's_rho', 'xi_rho')
            long_name_south = 'salinity south boundary condition'
            field_south = 'salt_south, scalar, series'
            dst_varname_east = 'salt_east'
            dimensions_east = ('time', 's_rho', 'eta_rho')
            long_name_east = 'salinity east boundary condition'
            field_east = 'salt_east, scalar, series'
            dst_varname_west = 'salt_west'
            dimensions_west = ('time', 's_rho', 'eta_rho')
            long_name_west = 'salinity west boundary condition'
            field_west = 'salt_west, scalar, series'
            units = 'PSU'
        else:
            raise ValueError('Undefined src_varname')


        if ndim == 3:
            # build intermediate zgrid
            zlevel = -z[::-1,0,0]
            nzlevel = len(zlevel)
            dst_zcoord = pyroms.vgrid.z_coordinate(dst_grd.vgrid.h, zlevel, nzlevel)
            dst_grdz = pyroms.grid.ROMS_Grid(dst_grd.name+'_Z', dst_grd.hgrid, dst_zcoord)

        # create variable in boudary file
        print('Creating variable', dst_varname_north)
        nc.createVariable(dst_varname_north, 'f8', dimensions_north, fill_value=spval)
        nc.variables[dst_varname_north].long_name = long_name_north
        nc.variables[dst_varname_north].long_name = long_name_north
        nc.variables[dst_varname_north].units = units
        nc.variables[dst_varname_north].field = field_north

        print('Creating variable', dst_varname_south)
        nc.createVariable(dst_varname_south, 'f8', dimensions_south, fill_value=spval)
        nc.variables[dst_varname_south].long_name = long_name_south
        nc.variables[dst_varname_south].units = units
        nc.variables[dst_varname_south].field = field_south

        print('Creating variable', dst_varname_east)
        nc.createVariable(dst_varname_east, 'f8', dimensions_east, fill_value=spval)
        nc.variables[dst_varname_east].long_name = long_name_east
        nc.variables[dst_varname_east].units = units
        nc.variables[dst_varname_east].field = field_east

        print('Creating variable', dst_varname_west)
        nc.createVariable(dst_varname_west, 'f8', dimensions_west, fill_value=spval)
        nc.variables[dst_varname_west].long_name = long_name_west
        nc.variables[dst_varname_west].units = units
        nc.variables[dst_varname_west].field = field_west


        # remapping
        print('remapping', dst_varname, 'from', src_grd.name, \
                  'to', dst_grd.name)
        print('time =', time)


        if ndim == 3:
           print('flood the grid')
            src_varz = pyroms_toolbox.Grid_HYCOM.flood_fast(src_var, src_grd, pos=pos, spval=spval, \
                                    dxy=dxy, cdepth=cdepth, kk=kk)
        else:
            src_varz = src_var

        # horizontal interpolation using scrip weights
        print('horizontal interpolation using xESMF')
        dst_varz = regrid_GLBy(src_varz, method='nearest_s2d')

        if ndim == 3:
            # vertical interpolation from standard z level to sigma
            print('vertical interpolation from standard z level to sigma')
            dst_var_north = pyroms.remapping.z2roms(dst_varz[::-1, Mp-1:Mp, :], \
                              dst_grdz, dst_grd, Cpos=Cpos, spval=spval, \
                              flood=False, irange=(0,Lp), krange=(Mp-1,Mp))
            dst_var_south = pyroms.remapping.z2roms(dst_varz[::-1, 0:1, :], \
                              dst_grdz, dst_grd, Cpos=Cpos, spval=spval, \
                              flood=False, irange=(0,Lp), krange=(0,1))
            dst_var_east = pyroms.remapping.z2roms(dst_varz[::-1, :, Lp-1:Lp], \
                              dst_grdz, dst_grd, Cpos=Cpos, spval=spval, \
                              flood=False, irange=(Lp-1,Lp), krange=(0,Mp))
            dst_var_west = pyroms.remapping.z2roms(dst_varz[::-1, :, 0:1], \
                              dst_grdz, dst_grd, Cpos=Cpos, spval=spval, \
                              flood=False, irange=(0,1), krange=(0,Mp))
        else:
            dst_var_north = dst_varz[-1, :]
            dst_var_south = dst_varz[0, :]
            dst_var_east = dst_varz[:, -1]
            dst_var_west = dst_varz[:, 0]
       # write data in destination file
        print('write data in destination file')
        nc.variables['time'][t] = time #**here also i changed nc.variables['time'][0] to nc.variables['time'][t] all below [0] index to [t]**
        nc.variables[dst_varname_north][t] = np.squeeze(dst_var_north)
        nc.variables[dst_varname_south][t] = np.squeeze(dst_var_south)
        nc.variables[dst_varname_east][t] = np.squeeze(dst_var_east)
        nc.variables[dst_varname_west][t] = np.squeeze(dst_var_west)

        # close file
        nc.close()
        cdf.close()

    if src_varname == 'SSH':#these two lines are out of above for loop.
            return dst_varz

Any Help will be Appreciable.
Thank you.

Hi @kshedstrom
Hope you everything is fine.
I have solved the timestamp problem but still stuck at depth k problem
I am getting k depth as null.
Can you please guide me how to solve the k depth problem , I should get k 1;40 which i am getting in my final file.
please let me know where i have to change the code line.

either j value should be shift to k or k i have to create.
For reference final month file detail as below:

yes? use month.nc 
           *** NOTE: Coordinates out of order or missing on axis time at subscript 31
           *** NOTE: A dummy axis of subscripts will be used
           *** NOTE:
           *** NOTE: Could not adjust grid for variable h
           *** NOTE: Axes in grids may be inconsistent.
           *** NOTE:
           *** NOTE: Could not adjust grid for variable lon_u
           *** NOTE: Axes in grids may be inconsistent.
           *** NOTE:
           *** NOTE: Could not adjust grid for variable lon_v
           *** NOTE: Axes in grids may be inconsistent.
yes? show data
     currently SET data sets:
    1> ./month.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     ...       ...
 TIME     time                             ...       ...       ...       1:31
       (invalid coordinate axis)
 ZETA_NORTH
          free-surface north boundary con  1:1081    ...       ...       1:31
 ZETA_SOUTH
          free-surface south boundary con  1:1081    ...       ...       1:31
 ZETA_EAST
          free-surface east boundary cond  1:757     ...       ...       1:31
 ZETA_WEST
          free-surface west boundary cond  1:757     ...       ...       1:31
 TEMP_NORTH
          potential temperature north bou  1:1081    1:50      ...       1:31
 TEMP_SOUTH
          potential temperature south bou  1:1081    1:50      ...       1:31
 TEMP_EAST
          potential temperature east boun  1:757     1:50      ...       1:31
 TEMP_WEST
          potential temperature west boun  1:757     1:50      ...       1:31
 SALT_NORTH
          salinity north boundary conditi  1:1081    1:50      ...       1:31
 SALT_SOUTH
          salinity south boundary conditi  1:1081    1:50      ...       1:31
 SALT_EAST
          salinity east boundary conditio  1:757     1:50      ...       1:31
 SALT_WEST
          salinity west boundary conditio  1:757     1:50      ...       1:31
 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     ...       ...
 U_NORTH  3D u-momentum north boundary co  1:1080    1:50      ...       1:31
 U_SOUTH  3D u-momentum south boundary co  1:1080    1:50      ...       1:31
 U_EAST   3D u-momentum east boundary con  1:757     1:50      ...       1:31
 U_WEST   3D u-momentum west boundary con  1:757     1:50      ...       1:31
 UBAR_NORTH
          2D u-momentum north boundary co  1:1080    ...       ...       1:31
 UBAR_SOUTH
          2D u-momentum south boundary co  1:1080    ...       ...       1:31
 UBAR_EAST
          2D u-momentum east boundary con  1:757     ...       ...       1:31
 UBAR_WEST
          2D u-momentum west boundary con  1:757     ...       ...       1:31
 V_NORTH  3D v-momentum north boundary co  1:1081    1:50      ...       1:31
 V_SOUTH  3D v-momentum south boundary co  1:1081    1:50      ...       1:31
 V_EAST   3D v-momentum east boundary con  1:756     1:50      ...       1:31
 V_WEST   3D v-momentum west boundary con  1:756     1:50      ...       1:31
 VBAR_NORTH
          2D v-momentum north boundary co  1:1081    ...       ...       1:31
 VBAR_SOUTH
          2D v-momentum south boundary co  1:1081    ...       ...       1:31
 VBAR_EAST
          2D v-momentum east boundary con  1:756     ...       ...       1:31
 VBAR_WEST
          2D v-momentum west boundary con  1:756     ...       ...       1:31
 
yes? 

Any Help will be Appreciable.
Thank you.

So you are getting 50 depths instead of 40. You tell it how many levels in the gridid.txt file:

id      = ARCTIC5
name    = ARCTIC5
grdfile = /import/AKWATERS/kshedstrom/gridpak/Arctic5/grid_Arctic_5.nc
N       = 50
grdtype = roms
Vtrans  = 4 
theta_s = 7 
theta_b = 2 
Tcline  = 250 

A lot of my examples have N=50. Do you have such a chunk in your gridid.txt?

@kshedstrom
Thanks for your reply and help.
I am really honor and pleased that i am clearing my doubts and you are so kind kind hearted and helpful person.
I am getting confuse in my j index there is not only 1:50 but some of the places 1:757 as well.
I think k value is not writing itself.
image
and i have gridid.txt there before it changed N=40 but still same scenario.
I am using previous IC created regrid_t.nc file, is it fine to use the same regrid_tc.nc file in Boundary condition creation.
and i am not able to find the python script where the gridid.txt was read and variable values were assigned from gridid.txt.
can you guide me please what was the python script name where gridid.txt file was read .
is the python script regrid_Glby.py or make_remap_weights_file.py
Any Help will be Appreciable.
Thank you.

If you are using xESMF, you do not need to run make_remap_weights_file.py. The file reading gridid.txt is make_bdry_file.py, the line with pyroms.grig.get_ROMS_grid('MYGRID'), where 'MYGRID' points to your grid blob in gridid.txt.

Using the old regrid_t.nc should be fine. It has the lateral remap weights, not the vertical ones.

I have no idea what code you are using to parse your output, but U_NORTH with 1:1080, 1:50 would be fine if you had 50 vertical levels.

Great its done now its showing j 1:40
Question 1 -but how to show depth in k index instead of j ? i.e K 1:40
image

Question 2- I am using ncrcat to merge all the daily files to montly file
ncrcat day*.nc month.nc
Is there any better approch to merge the daily files to montly single file ?
Any Help will be Appreciable.
Thank you.

Like I said, I have no idea what software you are using to show this. Therefore I can't tell you how to teach it about k.

Using ncrcat is what I do too. I don't know a better way.

@kshedstrom
ferret i am using to see the data.
Below is ncdump of the nc file.
image
Any Help will be Appreciable.
Thank you.

The file is likely to be fine at this point. Next is to look at it in ncview and/or see if ROMS will happily read it.

Hi @kshedstrom
Thank for such a wonderful Support.
You are really a very kind heart person and very very helpful person.
I sincerely appreciate your support. Your generous help has made an impact. Because of your help I am able to make a setup.
I appreciate the information and advice you have shared.
I am looking forward to implementing many of your suggestions, In fact I will love to work under your guidance,
Please let me know If you have any work related to software development or script.
Please accept my deepest thanks.