@@ -34,7 +34,7 @@ def get_comparison_descriptor(config, comparison_grid_name):
3434 Contains configuration options
3535
3636 comparison_grid_name : {'latlon', 'antarctic', 'arctic', 'north_atlantic',
37- 'north_pacific', 'subpolar_north_atlantic'}
37+ 'north_pacific', 'subpolar_north_atlantic', 'fris' }
3838 The name of the comparison grid to use for remapping.
3939
4040 Raises
@@ -125,15 +125,17 @@ def _get_projection_comparison_descriptor(config, comparison_grid_name):
125125 'arctic_extended' : 'ArcticExtended' ,
126126 'north_atlantic' : 'NorthAtlantic' ,
127127 'north_pacific' : 'NorthPacific' ,
128- 'subpolar_north_atlantic' : 'SubpolarNorthAtlantic' }
128+ 'subpolar_north_atlantic' : 'SubpolarNorthAtlantic' ,
129+ 'fris' : 'Fris' }
129130
130131 grid_suffixes = {'antarctic' : 'Antarctic_stereo' ,
131132 'arctic' : 'Arctic_stereo' ,
132133 'antarctic_extended' : 'Antarctic_stereo' ,
133134 'arctic_extended' : 'Arctic_stereo' ,
134135 'north_atlantic' : 'North_Atlantic' ,
135136 'north_pacific' : 'North_Pacific' ,
136- 'subpolar_north_atlantic' : 'Subpolar_North_Atlantic' }
137+ 'subpolar_north_atlantic' : 'Subpolar_North_Atlantic' ,
138+ 'fris' : 'Fris' }
137139
138140 if comparison_grid_name not in option_suffixes :
139141 raise ValueError (f'{ comparison_grid_name } is not one of the supported '
@@ -143,23 +145,32 @@ def _get_projection_comparison_descriptor(config, comparison_grid_name):
143145
144146 option_suffix = option_suffixes [comparison_grid_name ]
145147 grid_suffix = grid_suffixes [comparison_grid_name ]
146- width = config .getfloat (
147- section , f'comparison{ option_suffix } Width' )
148- option = f'comparison{ option_suffix } Height'
148+ option = f'comparison{ option_suffix } Bounds'
149149 if config .has_option (section , option ):
150- height = config .getfloat (section , option )
150+ bounds = config .getexpression (section , option )
151+ bounds = [1e3 * bound for bound in bounds ]
151152 else :
152- height = width
153+ width = config .getfloat (
154+ section , f'comparison{ option_suffix } Width' )
155+ option = f'comparison{ option_suffix } Height'
156+
157+ if config .has_option (section , option ):
158+ height = config .getfloat (section , option )
159+ else :
160+ height = width
161+ xmax = 0.5 * width * 1e3
162+ ymax = 0.5 * height * 1e3
163+ bounds = [- xmax , xmax , - ymax , ymax ]
164+ width = (bounds [1 ] - bounds [0 ]) / 1e3
165+ height = (bounds [3 ] - bounds [2 ]) / 1e3
153166 res = config .getfloat (
154167 section , f'comparison{ option_suffix } Resolution' )
155168
156- xmax = 0.5 * width * 1e3
157169 nx = int (width / res ) + 1
158- x = numpy .linspace (- xmax , xmax , nx )
170+ x = numpy .linspace (bounds [ 0 ], bounds [ 1 ] , nx )
159171
160- ymax = 0.5 * height * 1e3
161172 ny = int (height / res ) + 1
162- y = numpy .linspace (- ymax , ymax , ny )
173+ y = numpy .linspace (bounds [ 2 ], bounds [ 3 ] , ny )
163174
164175 mesh_name = f'{ width } x{ height } km_{ res } km_{ grid_suffix } '
165176 descriptor = ProjectionGridDescriptor .create (projection , x , y , mesh_name )
0 commit comments