def _setup_remappers(self): # {{{ """ Set up the remappers for remapping from the MPAS to the comparison grids. """ # Authors # ------- # Xylar Asay-Davis config = self.config # make reamppers mappingFilePrefix = 'map' self.remappers = {} for comparisonGridName in self.comparisonDescriptors: comparisonDescriptor = \ self.comparisonDescriptors[comparisonGridName] self.comparisonGridName = comparisonDescriptor.meshName mpasDescriptor = MpasMeshDescriptor( self.restartFileName, meshName=config.get('input', 'mpasMeshName')) self.mpasMeshName = mpasDescriptor.meshName self.remappers[comparisonGridName] = get_remapper( config=config, sourceDescriptor=mpasDescriptor, comparisonDescriptor=comparisonDescriptor, mappingFilePrefix=mappingFilePrefix, method=config.get('climatology', 'mpasInterpolationMethod'), logger=self.logger)
def setup_mpas_remapper(self, config): mpasMeshFileName = '{}/mpasMesh.nc'.format(self.datadir) comparisonDescriptor = \ get_comparison_descriptor(config, comparisonGridName='latlon') mpasDescriptor = MpasMeshDescriptor( mpasMeshFileName, meshName=config.get('input', 'mpasMeshName')) remapper = get_remapper( config=config, sourceDescriptor=mpasDescriptor, comparisonDescriptor=comparisonDescriptor, mappingFilePrefix='map', method=config.get( 'climatology', 'mpasInterpolationMethod')) return remapper
def get_mpas_descriptor(self): mpasMeshFileName = str(self.datadir.join('mpasMesh.nc')) timeSeriesFileName = str(self.datadir.join('timeSeries.0002-01-01.nc')) descriptor = MpasMeshDescriptor(mpasMeshFileName, meshName='oQU240') return (descriptor, mpasMeshFileName, timeSeriesFileName)
resolution. ''' from mpas_analysis.shared.interpolation import Remapper from mpas_analysis.shared.grid import MpasMeshDescriptor from mpas_analysis.shared.climatology import get_comparison_descriptor from mpas_analysis.configuration import MpasAnalysisConfigParser # replace with the MPAS mesh name inGridName = 'oQU240' # replace with the path to the desired mesh or restart file inGridFileName = '/media/xylar/extra_data/analysis/edison/G-QU240-master-intel/run/mpaso.rst.0001-01-06_00000.nc' config = MpasAnalysisConfigParser() config.read('mpas_analysis/config.default') # replace 1.0 with the desired resolution of the output mesh config.set('climatology', 'comparisonLatResolution', '1.0') config.set('climatology', 'comparisonLonResolution', '1.0') inDescriptor = MpasMeshDescriptor(inGridFileName, inGridName) outDescriptor = get_comparison_descriptor(config, 'latlon') outGridName = outDescriptor.meshName mappingFileName = 'map_{}_to_{}.nc'.format(inGridName, outGridName) remapper = Remapper(inDescriptor, outDescriptor, mappingFileName) remapper.build_mapping_file(method='bilinear')