...
 
......@@ -15,7 +15,7 @@ if rank == 0:
grid_res = float(sys.argv[4])
depth_layers = np.asarray(sys.argv[5].split(','), dtype=float)
var_list_raw = sys.argv[6].split(',')
varmatch = {'temp':'nodes', 'salinity':'nodes', 'u':'elements', 'v':'elements', 'zeta':'surface', 'h':'static_nodes'}
varmatch = {'temp':'nodes', 'salinity':'nodes', 'u':'elements', 'v':'elements', 'zeta':'surface'}
varlist = {}
for this_var in var_list_raw:
varlist[this_var] = varmatch[this_var]
......@@ -62,8 +62,23 @@ if rank == 0:
output_list = []
for this_dict in all_interped_data:
output_list.append(this_dict[this_var])
collected_interp_data[this_var] = np.ma.masked_invalid(np.vstack(output_list))
worker.fvcom_grid.select_ll = worker.fvcom_grid.ll
h = worker._Interpolater(worker.fvcom_grid.h)
grid_in_domain = pf.read.FileReader(worker.fvcom_file).in_domain(worker.regular_grid.mesh_lons, worker.regular_grid.mesh_lats)
h[~grid_in_domain] = np.nan
h = h.T
land_mask = np.zeros([h.shape[0], h.shape[1], len(depth_layers)])
for i, this_depth in enumerate(depth_layers):
if this_depth == 0:
land_mask[~np.isnan(h)] = 1
else:
land_mask[:,:,i][h > this_depth] = 1
# write to cmems format
fvcom = pf.read.FileReader(fvcom_file)
......@@ -80,7 +95,8 @@ if rank == 0:
'salinity':{'standard_name':'sea_water_salinity','units':'psu', 'missing_value':-32768, 'long_name':'Sea Water Salinity'},
'u':{'standard_name':'eastward_sea_water_velocity','units':'m s-1', 'missing_value':-32768, 'long_name':'Eastward Current Velocity'},
'v':{'standard_name':'northward_sea_water_velocity','units':'m s-1', 'missing_value':-32768, 'long_name':'Northward Current Velocity'},
'zeta':{'standard_name':'sea_surface_height_above_geoid','units':'m', 'missing_value':-32768,'long_name':'Sea surface height above geoid'}}
'zeta':{'standard_name':'sea_surface_height_above_geoid','units':'m', 'missing_value':-32768,'long_name':'Sea surface height above geoid'},
'mask':{'standard_name':'sea_binary_mask','units':'1', 'long_name':'Land-sea mask: sea = 1 ; land = 0'}}
globals = {'type': 'OPERATIONAL MODEL REGULAR GRID OUTPUT',
'title': 'Regularly gridded data interpolated from FVCOM output',
......@@ -102,14 +118,13 @@ if rank == 0:
outfile.add_variable('lon', worker.regular_grid.lons, ['lon'], attributes=all_attributes['lon'])
outfile.add_variable('lat', worker.regular_grid.lats, ['lat'], attributes=all_attributes['lat'])
outfile.add_variable('depth', worker.regular_grid.dep_lays, ['depth'], attributes=all_attributes['depth'])
outfile.add_variable('mask', land_mask, ['lon', 'lat', 'depth'], attributes=all_attributes['mask'])
outfile.add_variable('h', h, ['lon', 'lat'], attributes=all_attributes['h'])
for this_var, this_mode in varlist.items():
if this_mode == 'surface':
outfile.add_variable(this_var, collected_interp_data[this_var], ['time', 'lon', 'lat'],
attributes=all_attributes[this_var], ncopts=ncopts)
elif this_mode == 'static_nodes':
outfile.add_variable(this_var, collected_interp_data[this_var], ['lon', 'lat'],
attributes=all_attributes[this_var], ncopts=ncopts)
else:
outfile.add_variable(this_var, collected_interp_data[this_var], ['time', 'lon', 'lat', 'depth'],
attributes=all_attributes[this_var], ncopts=ncopts)
......
......@@ -7,6 +7,9 @@ fvcom_file_loc = sys.argv[1]
output_file = sys.argv[2]
write_vars = sys.argv[3].split(',')
write_vars.append('h')
write_vars.append('mask')
all_attributes = {'lon':{'var_name':'longitude','standard_name':'longitude', 'units':'degrees_east', 'long_name':'longitude', 'shape':'longitude'},
'lat':{'var_name':'latitude','standard_name':'latitude', 'units':'degrees_north', 'long_name':'latitude', 'shape':'latitude'},
'depth':{'standard_name':'depth', 'units':'m', 'long_name':'depth, measured downwards from free surface', 'axis':'Z', 'positive':'down', 'shape':'depth'},
......@@ -16,7 +19,10 @@ all_attributes = {'lon':{'var_name':'longitude','standard_name':'longitude', 'un
'salinity':{'var_name':'so','standard_name':'sea_water_salinity','units':'psu', 'missing_value':-32768, 'long_name':'Sea Water Salinity', 'shape':'time depth latitude longitude'},
'u':{'var_name':'uo', 'standard_name':'eastward_sea_water_velocity','units':'m s-1', 'missing_value':-32768, 'long_name':'Eastward Current Velocity', 'shape':'time depth latitude longitude'},
'v':{'var_name':'vo','standard_name':'northward_sea_water_velocity','units':'m s-1', 'missing_value':-32768, 'long_name':'Northward Current Velocity', 'shape':'time depth latitude longitude'},
'zeta':{'var_name':'zos','standard_name':'sea_surface_height_above_geoid','units':'m', 'missing_value':-32768,'long_name':'Sea surface height above geoid', 'shape':'time latitude longitude'}}
'zeta':{'var_name':'zos','standard_name':'sea_surface_height_above_geoid','units':'m', 'missing_value':-32768,'long_name':'Sea surface height above geoid', 'shape':'time latitude longitude'},
'mask':{'standard_name':'sea_binary_mask','units':'1', 'long_name':'Land-sea mask: sea = 1 ; land = 0', 'shape':'depth latitude longitude'},
'h':{'standard_name':'h', 'units':'m', 'long_name':'model bathymetry depth, measured downwards from geoid', 'axis':'Z', 'positive':'down', 'shape':'depth latitude longitude' }
}
all_type = {'add_offset':'float', 'scale_factor':'float', '_FillValue':'double'}
......
......@@ -3,4 +3,5 @@ default =
base_file=/${PORTAL_BASEDIR}/${FORECAST_YEAR}/${FORECAST_MONTH}/${OUTPUT_FILENAME}_hrly_${FORECAST_DAY}.nc
mkdir -p /${PORTAL_NCML_BASEDIR}/${FORECAST_YEAR}/${FORECAST_MONTH}/
dst_file=/${PORTAL_NCML_BASEDIR}/${FORECAST_YEAR}/${FORECAST_MONTH}/${OUTPUT_FILENAME}_hrly_${FORECAST_DAY}.ncml
rm ${dst_file} || true
python3 write_ncml_file.py ${base_file} ${dst_file} ${VARS}
[jinja2:suite.rc]
## Run properties
INITIAL_START_DATE='2019-05-04T00:00:00Z'
INITIAL_START_DATE='2020-01-01T00:00:00Z'
FINAL_CYCLE_POINT='NONE'
MAIL_TO='mbe@pml.ac.uk'
NPROCS=12
......@@ -17,7 +17,7 @@ GRID_LOWER_LEFT='-4.3,50.24'
GRID_UPPER_RIGHT='-4.05,50.55'
HORIZ_RES=0.001
DEPTH_LAYERS='0,3,5,10,15,20,25,30,40'
VARS='temp,salinity,u,v,zeta,h'
VARS='temp,salinity,u,v,zeta'
OUTPUT_DIR='data/sthenno1/scratch/modop/Model/FVCOM_tamar/estuary_output'
OUTPUT_FILENAME='tamar_estuary_001'
......