Package: roms2schism
ROMS2SCHISMA Python package for creatingSCHISMboundary condition forcing and hotstart files fromROMSoutput.Theroms2schismmodule contains four main sub-modules:schism: for loading the SCHISM grid (e.g.hgrid.ll,vgrid.in)boundary: for creating "type 4" SCHISM boundary conditions (uv3D.th.ncetc. files) from ROMS outputnudging: for creating temperature and salinity nudging files for the open boundary (TEM_nu.ncandSAL_nu.nc) from ROMS outputhotstart: for creating hotstart initial conditions (hotstart.nc) from ROMS outputLoading the SCHISM gridThe SCHISM grid can be loaded like this:importroms2schismasr2sschism=r2s.schism.schism_grid(schism_grid_file,schism_vgrid_file,schism_grid_dir,lonc,latc)The defaults for the parameters are:schism_grid_file:hgrid.llschism_vgrid_file:vgrid.inschism_grid_dir:./lonc,latc:NoneThelonc,latcparameters define a reference longitude and latitude, used to convert the horizontal grid coordinates (assumed to be longitude, latitude) to an approximate projected coordinate system. If these are not specified, default values are calculated by averaging the grid vertex coordinates.Creating boundary conditionsBoundary conditions can be created like this:r2s.boundary.make_boundary(schism,template,dates,start,end,roms_dir,roms_grid_filename,roms_grid_dir,dcrit)Theschismparameter is the SCHISM grid created above.Thetemplateanddatesparameters are used to define the sequence of filenames for the ROMS files used to create the boundary conditions. Thedatesparameter is an array ofdatetimeobjects. These are processed using thetemplatestring to create the filenames. All the ROMS date files must be in the directory specified byroms_dir.Thestartandendparameters define the start and enddatetimesof the simulation. Boundary conditions are created from ROMS results between these datetimes. They both default toNone, in which case they are set equal to the first and last datetimes in the ROMS results.Theroms_grid_filenameandroms_grid_dirparameters can be used to specify a ROMS grid file. This may be needed if the ROMS results do not contain theu_eastwardandv_northwardfields, in which case they are reconstructed (rotated and de-staggered) from theuandvfields. Otherwise, these parameters do not need to be specified.Thedcritparameter specifies a critical distance used to avoid interpolating ROMS results over land. It should generally be slightly larger than the ROMS grid resolution. If SCHISM grid points are further than this distance from the nearest ROMS grid point, nearest neighbour interpolation is used instead of bilinear interpolation.Creating nudging filesNudging files for temperature and salinity can be created like this:r2s.nudging.make_nudging(schism,template,dates,start,end,roms_dir,roms_grid_filename,roms_grid_dir,dcrit)The parameters for nudging are the same as those for creating the boundary conditions. The only difference is that typically nudging files are created from time-averaged ROMS results (e.g. daily averages), so thetemplateparameter will be different.Creating hotstart initial conditionsHotstart files can be created like this:r2s.hotstart.make_hotstart(schism,roms_data_filename,start,roms_dir,roms_grid_filename,roms_grid_dir,dcrit,h0)For the initial conditions, only one ROMS data file is needed, specified via theroms_data_filenameparameter. Most of the other parameters are the same as for creating boundary conditions and nudging. Theh0parameter (default 0.01 m) specifies the water depth below which SCHISM nodes will be considered dry at the start of the run.Examplefromdatetimeimportdatetime,timedeltaimportnumpyasnpimportroms2schismasr2s# set up dates corresponding to ROMS files to be read:start_filedate=datetime(2017,1,1)ndays=30dates=start_filedate+np.arange(ndays)*timedelta(days=1)start_date=datetime(2017,1,12)roms_dir='/path/to/roms/data/'dcrit=7e3# should be slightly larger than ROMS grid resolution# read SCHISM grid:schism=r2s.schism.schism_grid()# create boundary forcing files:template="foo_his_%Y%m%d.nc"r2s.boundary.make_boundary(schism,template,dates,start_date,roms_dir=roms_dir,dcrit=dcrit)# create boundary nudging files for T, S:template="foo_avg_%Y%m%d.nc"r2s.nudging.make_nudging(schism,template,dates,start_date,roms_dir=roms_dir,dcrit=dcrit)# create hotstart.nc file:roms_data_filename="foo_his_20170101.nc"r2s.hotstart.make_hotstart(schism,roms_data_filename,start_date,roms_dir=roms_dir,dcrit=dcrit)InstallationROMS2SCHISM can be installed from PyPI viapip:pip install roms2schism