Skip to content

Commit

Permalink
Merge pull request #1071 from irenavankova/add_fris_comparison_grids
Browse files Browse the repository at this point in the history
Add FRIS comparison grid
  • Loading branch information
xylar authored Mar 5, 2025
2 parents e33a335 + 737f5c2 commit 402df25
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 16 deletions.
20 changes: 20 additions & 0 deletions mpas_analysis/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ comparisonSubpolarNorthAtlanticWidth = 7000.
comparisonSubpolarNorthAtlanticHeight = 4000.
comparisonSubpolarNorthAtlanticResolution = 20.

# The comparison FRIS Antarctic polar stereographic grid size and resolution in km
comparisonFrisBounds = [-1800., -400., 100., 1500.]
# comparisonFrisWidth = 6000.
comparisonFrisResolution = 10.

# interpolation order for model and observation results. Likely values are
# 'bilinear', 'neareststod' (nearest neighbor) or 'conserve'
mpasInterpolationMethod = bilinear
Expand Down Expand Up @@ -500,6 +505,21 @@ useCartopyCoastline = True
latLines = np.arange(-80., 81., 10.)
lonLines = np.arange(-180., 181., 30.)

[plot_fris]
## options related to FRIS Antarctic projection plots

# figure sizes for different numbers of panels and layouts
onePanelFigSize = (8, 8.5)
threePanelVertFigSize = (8, 22)
threePanelHorizFigSize = (22, 7.5)

# whether to use the cartopy coastline (as opposed to the model coastline)
useCartopyCoastline = True

# latitude and longitude grid lines
latLines = np.arange(-80., 81., 10.)
lonLines = np.arange(-180., 181., 30.)

[html]
## options related to generating a webpage to display the analysis

Expand Down
35 changes: 23 additions & 12 deletions mpas_analysis/shared/climatology/comparison_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_comparison_descriptor(config, comparison_grid_name):
Contains configuration options
comparison_grid_name : {'latlon', 'antarctic', 'arctic', 'north_atlantic',
'north_pacific', 'subpolar_north_atlantic'}
'north_pacific', 'subpolar_north_atlantic', 'fris'}
The name of the comparison grid to use for remapping.
Raises
Expand Down Expand Up @@ -125,15 +125,17 @@ def _get_projection_comparison_descriptor(config, comparison_grid_name):
'arctic_extended': 'ArcticExtended',
'north_atlantic': 'NorthAtlantic',
'north_pacific': 'NorthPacific',
'subpolar_north_atlantic': 'SubpolarNorthAtlantic'}
'subpolar_north_atlantic': 'SubpolarNorthAtlantic',
'fris': 'Fris'}

grid_suffixes = {'antarctic': 'Antarctic_stereo',
'arctic': 'Arctic_stereo',
'antarctic_extended': 'Antarctic_stereo',
'arctic_extended': 'Arctic_stereo',
'north_atlantic': 'North_Atlantic',
'north_pacific': 'North_Pacific',
'subpolar_north_atlantic': 'Subpolar_North_Atlantic'}
'subpolar_north_atlantic': 'Subpolar_North_Atlantic',
'fris': 'Fris'}

if comparison_grid_name not in option_suffixes:
raise ValueError(f'{comparison_grid_name} is not one of the supported '
Expand All @@ -143,23 +145,32 @@ def _get_projection_comparison_descriptor(config, comparison_grid_name):

option_suffix = option_suffixes[comparison_grid_name]
grid_suffix = grid_suffixes[comparison_grid_name]
width = config.getfloat(
section, f'comparison{option_suffix}Width')
option = f'comparison{option_suffix}Height'
option = f'comparison{option_suffix}Bounds'
if config.has_option(section, option):
height = config.getfloat(section, option)
bounds = config.getexpression(section, option)
bounds = [1e3 * bound for bound in bounds]
else:
height = width
width = config.getfloat(
section, f'comparison{option_suffix}Width')
option = f'comparison{option_suffix}Height'

if config.has_option(section, option):
height = config.getfloat(section, option)
else:
height = width
xmax = 0.5 * width * 1e3
ymax = 0.5 * height * 1e3
bounds = [-xmax, xmax, -ymax, ymax]
width = (bounds[1] - bounds[0]) / 1e3
height = (bounds[3] - bounds[2]) / 1e3
res = config.getfloat(
section, f'comparison{option_suffix}Resolution')

xmax = 0.5 * width * 1e3
nx = int(width / res) + 1
x = numpy.linspace(-xmax, xmax, nx)
x = numpy.linspace(bounds[0], bounds[1], nx)

ymax = 0.5 * height * 1e3
ny = int(height / res) + 1
y = numpy.linspace(-ymax, ymax, ny)
y = numpy.linspace(bounds[2], bounds[3], ny)

mesh_name = f'{width}x{height}km_{res}km_{grid_suffix}'
descriptor = ProjectionGridDescriptor.create(projection, x, y, mesh_name)
Expand Down
6 changes: 3 additions & 3 deletions mpas_analysis/shared/projection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

known_comparison_grids = ['latlon', 'antarctic', 'antarctic_extended',
'arctic', 'arctic_extended', 'north_atlantic',
'north_pacific', 'subpolar_north_atlantic']
'north_pacific', 'subpolar_north_atlantic', 'fris']


def get_pyproj_projection(comparison_grid_name):
Expand Down Expand Up @@ -49,7 +49,7 @@ def get_pyproj_projection(comparison_grid_name):

if comparison_grid_name == 'latlon':
raise ValueError('latlon is not a projection grid.')
elif comparison_grid_name in ['antarctic', 'antarctic_extended']:
elif comparison_grid_name in ['antarctic', 'antarctic_extended', 'fris']:
projection = pyproj.Proj(
'+proj=stere +lat_ts=-71.0 +lat_0=-90 +lon_0=0.0 +k_0=1.0 '
'+x_0=0.0 +y_0=0.0 +ellps=WGS84')
Expand Down Expand Up @@ -105,7 +105,7 @@ def get_cartopy_projection(comparison_grid_name):
if comparison_grid_name == 'latlon':
raise ValueError('latlon is not a projection grid.')

elif comparison_grid_name in ['antarctic', 'antarctic_extended']:
elif comparison_grid_name in ['antarctic', 'antarctic_extended', 'fris']:
projection = cartopy.crs.Stereographic(
central_latitude=-90., central_longitude=0.0,
true_scale_latitude=-71.0)
Expand Down
2 changes: 1 addition & 1 deletion suite/template.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ usePostprocessingScript = True

# comparison grid(s) ('latlon', 'antarctic') on which to plot analysis
comparisonGrids = ['latlon', 'antarctic', 'arctic', 'north_atlantic',
'north_pacific']
'north_pacific', 'fris']

0 comments on commit 402df25

Please sign in to comment.