File tree 1 file changed +13
-4
lines changed
1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 20
20
import xarray
21
21
import numpy
22
22
import iris
23
+ import mule
24
+ import os
25
+
23
26
24
27
"""
25
28
Different grid types
@@ -178,11 +181,17 @@ def to_scrip(self):
178
181
class UMGrid (LonLatGrid ):
179
182
@classmethod
180
183
def from_mask (cls , mask_path ):
181
- mask = iris .load_cube (mask_path , iris .AttributeConstraint (STASH = 'm01s00i030' ))
182
- mask .coord ('latitude' ).var_name = 'lat'
183
- mask .coord ('longitude' ).var_name = 'lon'
184
+ umfile = mule .load_umfile (mask_path )
185
+ mask_field = None
186
+ for f in umfile .fields :
187
+ if f .lbuser4 == 30 :
188
+ mask_field = f
189
+ break
190
+
191
+ mask = xarray .DataArray (mask_field .get_data (), dims = ['lat' , 'lon' ], name = os .path .basename (mask_path ))
192
+ mask .coords ['lon' ] = mask_field .bzx + (1 + numpy .arange (mask .shape [1 ])) * mask_field .bdx
193
+ mask .coords ['lat' ] = mask_field .bzy + (1 + numpy .arange (mask .shape [0 ])) * mask_field .bdy
184
194
185
- mask = xarray .DataArray .from_iris (mask ).load ()
186
195
mask = mask .where (mask == 0 )
187
196
188
197
mask .lon .attrs ['standard_name' ] = 'longitude'
You can’t perform that action at this time.
0 commit comments