def create_da_bry_std(filename, eta_rho=10, xi_rho=10, s_rho=1, bry=4, reftime=default_epoch, clobber=False, cdl=None, title="My BRY STD"): """ Create a boundaries standard deviation file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction s_rho: int, optional number of s-levels bry: int, optional number of open boundaries to specify reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser(_cdl_dir + "s4dvar_std_b.cdl" if cdl is None else cdl) # Fill in the appropriate dimension values dims = _set_grid_dimensions(dims, eta_rho, xi_rho, s_rho) dims["IorJ"] = max(eta_rho, xi_rho) dims["boundary"] = bry vars = _set_time_ref(vars, "ocean_time", reftime) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def _create_generic_file(filename, cdl, eta_rho, xi_rho, s_rho, reftime=None, clobber=False, title="ROMS"): """ internal method: Generic file creator that uses ocean_time """ # Generate the Structure dims, vars, attr = cdl_parser(cdl) # Fill in the appropriate dimension values dims = _set_grid_dimensions(dims, eta_rho, xi_rho, s_rho) if reftime is not None: vars = _set_time_ref(vars, "ocean_time", reftime) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_frc_direct(filename, eta_rho=10, xi_rho=10, reftime=default_epoch, clobber=False, cdl=None, title="My Forcing"): """ Create a direct surface forcing file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser(_cdl_dir + "frc_direct.cdl" if cdl is None else cdl) # Fill in the appropriate dimension values dims = { 'y_rho': eta_rho, 'y_u': eta_rho, 'y_v': eta_rho - 1, 'x_rho': xi_rho, 'x_u': xi_rho - 1, 'x_v': xi_rho, 'frc_time': 0 } vars = _set_time_ref(vars, 'frc_time', reftime) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_zlevel(filename, lat=10, lon=10, depth=1, reftime=default_epoch, clobber=False, cdl=None, title="Zlevel Model Data", dims=2): """ Create an time varying model standard deviation file Parameters ---------- filename : string name and path of file to create lat: int, optional number of latitudinal rows lon: int, optional number of longitudinal columns depth: int, optional number of z-levels reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title dims: int, optional number of dimensions to use for lat/lon Returns ------- nc, netCDF4 object """ if cdl == None: if dims == 1: cdlfile = _cdl_dir + "zlevel_1d.cdl" else: cdlfile = _cdl_dir + "zlevel_2d.cdl" else: cdlfile = cdl # Generate the Structure dims, vars, attr = cdl_parser(cdlfile) # Fill in the appropriate dimension values dims["lat"] = lat dims["lon"] = lon dims["depth"] = depth vars = _set_time_ref(vars, "time", reftime) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_frc_wind(filename, eta_rho=10, xi_rho=10, s_rho=1, cycle=None, reftime=default_epoch, clobber=False, cdl=None, title="My Winds"): """ Create a surface wind stress forcing file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction s_rho: int, optional number of s-levels cycle: int or None, optional The number of days before cycling the forcing records reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser(_cdl_dir + "frc_windstress.cdl" if cdl is None else cdl) # Fill in the appropriate dimension values dims = _set_grid_dimensions(dims, eta_rho, xi_rho, s_rho) vars = _set_time_ref(vars, "sms_time", reftime, cycle) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_da_ray_obs(filename, ray_datum=1, provenance="None", reftime=default_epoch, clobber=False, cdl=None, title="My Observations"): """ Create an acoustic ray assimilation observations file Parameters ---------- filename : string name and path of file to create ray_datum: int, optional Number of rays to assimilate provenance: string, optional Description of the provenance values reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser(_cdl_dir + "s4dvar_obs_ray.cdl" if cdl is None else cdl) # Fill in the appropriate dimension values dims["ray_datum"] = ray_datum vars = _set_time_ref(vars, "obs_time", reftime) # Set the provenance values in the global attributes attr["obs_provenance"] = provenance # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_zlevel_grid(filename, lat=10, lon=10, depth=1, clobber=False, cdl=None, title="Zlevel Grid", dims=2): """ Create z-level grid file Parameters ---------- filename : string name and path of file to create lat: int, optional number of latitudinal rows lon: int, optional number of longitudinal columns depth: int, optional number of z-levels clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title dims: int, optional number of dimensions to use for lat/lon Returns ------- nc, netCDF4 object """ if cdl == None: if dims == 1: cdlfile = _cdl_dir + "zlevel_1d_grid.cdl" else: cdlfile = _cdl_dir + "zlevel_2d_grid.cdl" else: cdlfile = cdl # Generate the Structure dims, vars, attr = cdl_parser(cdlfile) # Fill in the appropriate dimension values dims["lat"] = lat dims["lon"] = lon dims["depth"] = depth # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_grid(filename, eta_rho=10, xi_rho=10, s_rho=1, clobber=False, cdl=None, title="My Grid"): """ Create a new, blank grid file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction s_rho: int, optional number of s-levels clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser(_cdl_dir + "roms_grid.cdl" if cdl is None else cdl) # Fill in the appropriate dimension values dims = _set_grid_dimensions(dims, eta_rho, xi_rho, s_rho) print(dims) # Create the grid file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_frc_flux(filename, eta_rho=10, xi_rho=10, ntimes=1, cycle=None, reftime=default_epoch, clobber=False, cdl=None, title="My Flux"): """ Create a surface flux forcing file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction s_rho: int, optional number of s-levels ntimes: int, optional number of time records (climatology files do not have unlimited dimension) cycle: int or None, optional The number of days before cycling the forcing records reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser( _cdl_dir + "frc_fluxclm.cdl" if cdl is None else cdl) # Fill in the appropriate dimension values dims = _set_grid_dimensions(dims, eta_rho, xi_rho, 1) times = ("srf_time", "shf_time", "swf_time", "sss_time") for n in times: dims[n] = ntimes vars = _set_time_ref(vars, times, reftime) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_tide(filename, eta_rho=10, xi_rho=10, s_rho=1, ntides=1, reftime=default_epoch, clobber=False, title="My Tides"): """ Create a barotropic tide forcing file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction s_rho: int, optional number of s-levels ntides: int, optional number of tidal frequencies to force with reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser(_cdl_dir + "frc_tides.cdl") # Fill in the appropriate dimension values dims = _set_grid_dimensions(dims, eta_rho, xi_rho, s_rho) dims["tide_period"] = ntides # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_psource(filename, nriver=1, s_rho=5, reftime=default_epoch, clobber=False, cdl=None, title="My River"): """ Create a new, blank point source file Parameters ---------- filename : string name and path of file to create nriver : int, optional number of rivers to put in file s_rho: int, optional number of s-levels reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser(_cdl_dir + "frc_rivers.cdl" if cdl is None else cdl) # Fill in the appropriate river values dims["river"] = nriver dims["s_rho"] = s_rho vars = _set_time_ref(vars, "river_time", reftime) # Create the river file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_da_obs(filename, state_variable=20, survey=1, provenance=None, clobber=False, cdl=None, title="My Observations"): """ Create an assimilation observations file Parameters ---------- filename : string name and path of file to create survey: int, optional number of surveys in the file state_variable: int, optional number of state variables in the observations provenance: string, optional Description of the provenance values reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser( _cdl_dir + "s4dvar_obs.cdl" if cdl is None else cdl) # Fill in the appropriate dimension values dims["survey"] = survey dims["state_variable"] = state_variable # Set the provenance values in the global attributes if provenance is not None: attr["obs_provenance"] = str(provenance) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title, format="NETCDF3_64BIT") # Return the new file return _nc
def create_frc_flux(filename, eta_rho=10, xi_rho=10, ntimes=1, cycle=None, reftime=default_epoch, clobber=False, title="My Flux"): """ Create a surface flux forcing file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction s_rho: int, optional number of s-levels ntimes: int, optional number of time records (climatology files do not have unlimited dimension) cycle: int or None, optional The number of days before cycling the forcing records reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser(_cdl_dir + "frc_fluxclm.cdl") # Fill in the appropriate dimension values dims = _set_grid_dimensions(dims, eta_rho, xi_rho, 1) times = ("srf_time", "shf_time", "swf_time", "sss_time") for n in times: dims[n] = ntimes vars = _set_time_ref(vars, times, reftime) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_da_bry_std(filename, eta_rho=10, xi_rho=10, s_rho=1, bry=4, reftime=default_epoch, clobber=False, cdl=None, title="My BRY STD"): """ Create a boundaries standard deviation file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction s_rho: int, optional number of s-levels bry: int, optional number of open boundaries to specify reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser( _cdl_dir + "s4dvar_std_b.cdl" if cdl is None else cdl) # Fill in the appropriate dimension values dims = _set_grid_dimensions(dims, eta_rho, xi_rho, s_rho) dims["IorJ"] = max(eta_rho, xi_rho) dims["boundary"] = bry vars = _set_time_ref(vars, "ocean_time", reftime) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_frc_direct(filename, eta_rho=10, xi_rho=10, reftime=default_epoch, clobber=False, cdl=None, title="My Forcing"): """ Create a direct surface forcing file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser( _cdl_dir + "frc_direct.cdl" if cdl is None else cdl) # Fill in the appropriate dimension values dims = {'y_rho': eta_rho, 'y_u': eta_rho, 'y_v': eta_rho - 1, 'x_rho': xi_rho, 'x_u': xi_rho - 1, 'x_v': xi_rho, 'frc_time': 0} vars = _set_time_ref(vars, 'frc_time', reftime) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_da_ray_obs(filename, ray_datum=1, provenance="None", reftime=default_epoch, clobber=False, cdl=None, title="My Observations"): """ Create an acoustic ray assimilation observations file Parameters ---------- filename : string name and path of file to create ray_datum: int, optional Number of rays to assimilate provenance: string, optional Description of the provenance values reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser( _cdl_dir + "s4dvar_obs_ray.cdl" if cdl is None else cdl) # Fill in the appropriate dimension values dims["ray_datum"] = ray_datum vars = _set_time_ref(vars, "obs_time", reftime) # Set the provenance values in the global attributes attr["obs_provenance"] = provenance # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_frc_qcorr(filename, eta_rho=10, xi_rho=10, s_rho=1, cycle=None, reftime=default_epoch, clobber=False, cdl=None, title="My Qcorrection"): """ Create a Q Correction forcing file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction s_rho: int, optional number of s-levels cycle: int or None, optional The number of days before cycling the forcing records reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser( _cdl_dir + "frc_qcorr.cdl" if cdl is None else cdl) # Fill in the appropriate dimension values dims = _set_grid_dimensions(dims, eta_rho, xi_rho, s_rho) vars = _set_time_ref(vars, "sst_time", reftime, cycle) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_grid(filename, eta_rho=10, xi_rho=10, s_rho=1, clobber=False, cdl=None, title="My Grid"): """ Create a new, blank grid file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction s_rho: int, optional number of s-levels clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser( _cdl_dir + "roms_grid.cdl" if cdl is None else cdl) # Fill in the appropriate dimension values dims = _set_grid_dimensions(dims, eta_rho, xi_rho, s_rho) print(dims) # Create the grid file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_tide(filename, eta_rho=10, xi_rho=10, s_rho=1, ntides=1, reftime=default_epoch, clobber=False, title="My Tides"): """ Create a barotropic tide forcing file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction s_rho: int, optional number of s-levels ntides: int, optional number of tidal frequencies to force with reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser(_cdl_dir + "frc_tides.cdl") # Fill in the appropriate dimension values dims = _set_grid_dimensions(dims, eta_rho, xi_rho, s_rho) dims["tide_period"] = ntides # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_psource(filename, nriver=1, s_rho=5, reftime=default_epoch, clobber=False, cdl=None, title="My River"): """ Create a new, blank point source file Parameters ---------- filename : string name and path of file to create nriver : int, optional number of rivers to put in file s_rho: int, optional number of s-levels reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition cdl: string, optional, Use the specified CDL file as the definition for the new netCDF file. title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser( _cdl_dir + "frc_rivers.cdl" if cdl is None else cdl) # Fill in the appropriate river values dims["river"] = nriver dims["s_rho"] = s_rho vars = _set_time_ref(vars, "river_time", reftime) # Create the river file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def _create_generic_file(filename, cdl, eta_rho, xi_rho, s_rho, reftime=None, clobber=False, title="ROMS"): """ internal method: Generic file creator that uses ocean_time """ # Generate the Structure dims, vars, attr = cdl_parser(_cdl_dir + cdl) # Fill in the appropriate dimension values dims = _set_grid_dimensions(dims, eta_rho, xi_rho, s_rho) if reftime is not None: vars = _set_time_ref(vars, "ocean_time", reftime) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_da_frc_std(filename, eta_rho=10, xi_rho=10, s_rho=1, reftime=default_epoch, clobber=False, title="My FRC STD"): """ Create a forcing standard deviation file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction s_rho: int, optional number of s-levels reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser(_cdl_dir + "s4dvar_std_f.cdl") # Fill in the appropriate dimension values dims = _set_grid_dimensions(dims, eta_rho, xi_rho, s_rho) vars = _set_time_ref(vars, "ocean_time", reftime) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_da_model_std(filename, eta_rho=10, xi_rho=10, s_rho=1, reftime=default_epoch, clobber=False, title="My Model STD"): """ Create an time varying model standard deviation file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction s_rho: int, optional number of s-levels reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser(_cdl_dir + "s4dvar_std_m.cdl") # Fill in the appropriate dimension values dims = _set_grid_dimensions(dims, eta_rho, xi_rho, s_rho) vars = _set_time_ref(vars, "ocean_time", reftime) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_frc_bulk(filename, lat=10, lon=10, reftime=default_epoch, clobber=False, title="My Forcing"): """ Create a bulk flux forcing file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser(_cdl_dir + "frc_bulk.cdl") # Fill in the appropriate dimension values dims["lat"] = lat dims["lon"] = lon vars = _set_time_ref(vars, "frc_time", reftime) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_frc_bulk(filename, lat=10, lon=10, reftime=default_epoch, clobber=False, title="My Forcing"): """ Create a bulk flux forcing file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction reftime: datetime, optional date of epoch for time origin in netcdf clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser(_cdl_dir + "frc_bulk.cdl") # Fill in the appropriate dimension values dims["lat"] = lat dims["lon"] = lon vars = _set_time_ref(vars, "time", reftime) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc
def create_nudge_coef(filename, eta_rho=10, xi_rho=10, s_rho=1, clobber=False, title="My Nudging"): """ Create a nudging coefficients file Parameters ---------- filename : string name and path of file to create eta_rho: int, optional number of rows in the eta direction xi_rho: int, optional number of columns in the xi direction s_rho: int, optional number of s-levels clobber: bool, optional If True, clobber any existing files and recreate. If False, use the existing file definition title: string, optional netcdf attribute title Returns ------- nc, netCDF4 object """ # Generate the Structure dims, vars, attr = cdl_parser(_cdl_dir + "nudge_coef.cdl") # Fill in the appropriate dimension values dims = _set_grid_dimensions(dims, eta_rho, xi_rho, s_rho) # Create the file _nc = ncgen(filename, dims=dims, vars=vars, attr=attr, clobber=clobber, title=title) # Return the new file return _nc