Creating Boundary Condition for ROMS Grid using GODAS Data
prasannakanti opened this issue · 20 comments
While running the script for creating boundary condition I got the following error:
Traceback (most recent call last):
File "/home/prasanna/miniconda/envs/xesmf_env/lib/python3.7/multiprocessing/pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "/home/prasanna/miniconda/envs/xesmf_env/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar
return list(map(*args))
File "withcomment_Boundary_condition_genertion_from_Godas_to_ROMS.py", line 65, in do_file
zeta = remap_bdry(file, 'SSH', src_grd, dst_grd, dst_dir=dst_dir)
File "/home/prasanna/MOM6/GodasToROMS_BC/remap_bdry.py", line 43, in remap_bdry
src_var = cdf.variables[src_varname]
KeyError: 'SSH'
I am unable to find the exact problem. Can you please help me in this issue?
Is the variable "SSH" in the GODAS file?
Yes. There are ssh,salt,temp variables.
If the file has ssh, you should change the code to ssh from SSH.
Sorry madam. It was 'SSH' in the Godas file. I kept the same name as it is in Godas data.
Then I can't tell what the problem is. Is there a version of the script you can try without the multiprocessing? That might give more informative errors. Have you learned to use the pdb debugger?
No madam. I do not know how to use pdb debugger. I am checking the script again.Thank you.
This is my Godas dataset .
1> ./Godas_uvsshts_Jan.nc (default)
name title I J K L
U zonal current 1:720 1:410 1:40 1:31
V meridional current 1:720 1:410 1:40 1:31
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
ETA_T surface height on T cells 1:720 1:410 ... 1:31
WT vertical velocity T-points 1:720 1:410 1:40 1:31
MLD mixed layer depth 1:720 1:410 ... 1:31
AVERAGE_DT
Length of average period ... ... ... 1:31
Madam,
This ** line is the line where the error coming . src_varname is then defined below under if, elif condition.
cdf = netCDF.Dataset(src_file)
src_var = cdf.variables[src_varname]
time = cdf.variables['time'][0]
print(time)
#get missing value
spval = src_var._FillValue
src_var = cdf.variables[src_varname][0]
# 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 = ('ocean_time', 'eta_rho', 'xi_rho')
long_name = 'free-surface'
dst_varname_north = 'zeta_north'
dimensions_north = ('ocean_time', 'xi_rho')
long_name_north = 'free-surface north boundary condition'
field_north = 'zeta_north, scalar, series'
dst_varname_south = 'zeta_south'
@kshedstrom Madam, your help is required . Please help me a bit.
@kshedstrom Hope you are doing well. I created the boundary files. But I could not open then in Ferret. It is showing the following error.
us Godas_day_27_bdry_GODASROMSBC.nc
*** NOTE:
*** NOTE: Could not adjust grid for variable h
**ERROR: inconsistent data grids: File needs axis attributes on coordinate variables indicating correct directions
Kindly help me a little. But I can plot and check in python . Please help me .
You're asking me for help with ferret? Really?
If it wants more attributes, you can add them via Python or via the NCO package. ncatted -a ...
The real question is does ROMS happily read them?
Yes madam, I was so much disapointed when I could not open the .nc file in ferret. I thought you can help me. Python can read the files. I did not start any model run. Thank you.
I have not used ferret. Before Python I was doing a few things in NCL and before that I was playing with PDL (Perl Data Language). Both are now completely obsolete thanks to Python and xarray and all that. To view netcdf files I have been using ncview all along. Also "ncdump -h".
Thank you Madam for your time. I am new in python and using .nc file. I have checked and found it was a problem with the ferret version. It is opening in other ferret versions. Thank you again.
Madam,
I am facing another problem. I have used Data variables' _fill_value in the destination variables. But, when the destination variables coming, it is showing distinct fill_values. Even fill plot for temp and salt are coming odd without levels qualifier.
Did you start from one of my examples? Which one? I don't have a Godas example.
Yes madam. I started with your "CCS1_SODA3.3.1" example. I used almost the same code but the data source I used from GODAS.
The code should copy the source _FillValue to the destination variables. On the command line, can you look at "ncdump -h file" for both files? Here is from a boundary file from HYCOM:
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" ;
What can I say? This is again a ferret issue. Good that you found a work-around.