bin.MarsNest
The MarsNest executable does not accept any input.
The executable requires the presence of grid_spec files in the current directory. Test grid_spec files can be generated by running the AmesGCM with 0 days as the input.
Third-party Requirements:
numpy
argparse
netCDF4
matplotlib
os
Attributes
Functions
|
A decorator that wraps a function with error handling |
|
This function extract a subsample of a larger grid variable. It deals with wrapping around the longitudes on the edges of the grid. |
|
Return the path and basename of a file. If only the filename is provided, assume it is the current directory |
|
Return the line number given a file name. |
|
Return the North West and South East corner of a gridscspec file. |
|
Return the North West and South East corner of a gridscspec file. |
|
Test if a grid is nested in another grid. |
|
List all files in directory. |
|
Module Contents
- debug_wrapper(func)
A decorator that wraps a function with error handling based on the –debug flag.
If the –debug flag is set, it prints the full traceback of any exception that occurs. Otherwise, it prints a simplified error message.
- Parameters:
func (function) – The function to wrap.
- Returns:
The wrapped function.
- Return type:
function
- Raises:
Exception – If an error occurs during the function call.
TypeError – If the function is not callable.
ValueError – If the function is not found.
NameError – If the function is not defined.
AttributeError – If the function does not have the specified attribute.
ImportError – If the function cannot be imported.
RuntimeError – If the function cannot be run.
KeyError – If the function does not have the specified key.
IndexError – If the function does not have the specified index.
IOError – If the function cannot be opened.
OSError – If the function cannot be accessed.
EOFError – If the function cannot be read.
MemoryError – If the function cannot be allocated.
OverflowError – If the function cannot be overflowed.
ZeroDivisionError – If the function cannot be divided by zero.
StopIteration – If the function cannot be stopped.
KeyboardInterrupt – If the function cannot be interrupted.
SystemExit – If the function cannot be exited.
AssertionError – If the function cannot be asserted.
- extract_grid(lon, lat, varIN, lon_target, lat_target, window_lon, window_lat)
This function extract a subsample of a larger grid variable. It deals with wrapping around the longitudes on the edges of the grid. Args:
lon: 1D array of longitude -180/+180 lat: 1D array of latitudes -90/+90 varIN: 2D array var2IN(lat,lon) lon_target: float, center longitude of subgrid (e.g =-136.) lat_target: float, center latitude of subgrid (e.g =40.) window_lon: width of window in degree (e.g =10.) window_lat: heigth of window in degree (e.g. =5.)
- Returns:
lon_window: 1D array of truncated longitude (may not be increasing) lat_window: 1D array of truncated latitudes (may not be increasing) varIN_out: 2D array of subsample of varIN
- extract_path_basename(filename)
Return the path and basename of a file. If only the filename is provided, assume it is the current directory Args:
filename: e.g. ‘XXXXX.fixed.nc’, ‘./history/XXXXX.fixed.nc’ or ‘/home/user/history/XXXXX.fixed.nc’
- Returns:
filepath : ‘/home/user/history/XXXXX.fixed.nc’ in all the cases above basename: XXXXX.fixed.nc in all the cases above
*NOTE* This routine does not check for file existence and only operates on the provided input string.
- find_tile_number(filename)
Return the line number given a file name. (Spit grid_spec.nest03.tile8.nc as “grid_spec.nest03” “.tile” “8.nc” and remove “.nc”
- get_corners(poly_path)
Return the North West and South East corner of a gridscspec file. Args:
gridspec_filename: full path to a gridscpec file
- Return:
NWc,SEc =(lat,lon) of the two corners
- get_poly_path(gridspec_filename)
Return the North West and South East corner of a gridscspec file. Args:
gridspec_filename: full path to a gridscpec file
- Return:
poly = a numpy array size (N,(lat,lon) )with the corners
- is_child(poly_path_child, poly_path_parent)
Test if a grid is nested in another grid. Args:
poly_path_child: a polygon object wit the 4 corners of the child tile poly_path_parent: a polygon object wit the 4 corners of the parent tile
- Returns:
bool: True if all the corners of the child grids are contained within the path defined by the paretn grid
- list_full_paths(input_path)
List all files in directory.
- main()
- args = None
- debug
- f
- map_dir = '/nobackup/rurata/FMS_MARS_data/mars_topo.nc'
- nskip = 2
- parser
- parser
- thick_line = 0.5