diff --git a/CHANGELOG b/CHANGELOG index e7abef44c52f7faf9e1b455b41f5ae1afdf6013c..ed2436dda0fb006bcaf25178d5f50f3bb1450b6f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +1.0.2 + 2019/04/30 + + - Corrected error on MONARCH rotated NetCDF metadata + - Regional regular lat-lon domain + 1.0.1 2019/03/12 diff --git a/conf/hermes.conf b/conf/hermes.conf index 56d26d261a0ad626a0f119f705e529629a10aed2..8eb561086fcfb675578a2eeba982e7e67088be89 100644 --- a/conf/hermes.conf +++ b/conf/hermes.conf @@ -20,8 +20,9 @@ output_model = MONARCH # output_model = WRF_CHEM output_attributes = /data/global_attributes.csv -# ***** domain_type=[global, lcc, rotated, mercator] ***** -domain_type = global +# ***** domain_type=[global, regular, lcc, rotated, mercator] ***** +#domain_type = global +domain_type = regular # domain_type = lcc # domain_type = rotated # domain_type = mercator @@ -29,8 +30,17 @@ vertical_description = /data/profiles/vertical/Benchmark_15layers_ver auxiliar_files_path = /data/auxiliar_files/_ # if domain_type == global: - inc_lat = 1. - inc_lon = 1.40625 + #inc_lat = 1. + #inc_lon = 1.40625 + +# if domain_type == regular: + lat_orig = 30. + lon_orig = -30. + inc_lat = 0.05 + inc_lon = 0.1 + n_lat = 840 + n_lon = 900 + # if domain_type == rotated: #centre_lat = 35 diff --git a/hermesv3_gr/__init__.py b/hermesv3_gr/__init__.py index 5c4105cd39cc4181c773f21fc007b4d120968c8b..7863915fa5f8f014c64c8abff41a138e9b3cd4d3 100644 --- a/hermesv3_gr/__init__.py +++ b/hermesv3_gr/__init__.py @@ -1 +1 @@ -__version__ = "1.0.1" +__version__ = "1.0.2" diff --git a/hermesv3_gr/config/config.py b/hermesv3_gr/config/config.py index b61857d15e75b71bf365268ac16640ed0a117e7f..d174e04ab52e2125c975864146702e3b3704c886 100644 --- a/hermesv3_gr/config/config.py +++ b/hermesv3_gr/config/config.py @@ -19,6 +19,7 @@ from configargparse import ArgParser +import sys class Config(ArgParser): @@ -67,7 +68,7 @@ class Config(ArgParser): help='Path to the file that contains the global attributes.') p.add_argument('--domain_type', required=True, help='Type of domain to simulate.', - choices=['global', 'lcc', 'rotated', 'mercator']) + choices=['global', 'lcc', 'rotated', 'mercator', 'regular']) p.add_argument('--auxiliar_files_path', required=True, help='Path to the directory where the necessary auxiliary files will be created if them are ' + 'not created yet.') @@ -79,6 +80,12 @@ class Config(ArgParser): p.add_argument('--inc_lat', required=False, help='Latitude resolution for a global domain.', type=float) p.add_argument('--inc_lon', required=False, help='Longitude resolution for a global domain.', type=float) + # Regular lat-lon options: + p.add_argument('--lat_orig', required=False, help='Latitude of the corner of the first cell.', type=float) + p.add_argument('--lon_orig', required=False, help='Longitude of the corner of the first cell.', type=float) + p.add_argument('--n_lat', required=False, help='Number of latitude elements.', type=float) + p.add_argument('--n_lon', required=False, help='Number of longitude elements.', type=float) + # Rotated options p.add_argument('--centre_lat', required=False, help='Central geographic latitude of grid (non-rotated degrees). Corresponds to the TPH0D ' + @@ -157,7 +164,7 @@ class Config(ArgParser): if is_str: exec("options.{0} = options.{0}.replace('', options.input_dir)".format(item)) exec("options.{0} = options.{0}.replace('', options.domain_type)".format(item)) - if options.domain_type == 'global': + if options.domain_type == 'global' or options.domain_type == 'regular': exec("options.{0} = options.{0}.replace('', '{1}_{2}')".format( item, options.inc_lat, options.inc_lon)) elif options.domain_type == 'rotated': diff --git a/hermesv3_gr/hermes.py b/hermesv3_gr/hermes.py index f094111a0b08295c87d3c21d873e2e816251ca66..52d46cba127a6672cd2439c69a37ee53b23d0e22 100755 --- a/hermesv3_gr/hermes.py +++ b/hermesv3_gr/hermes.py @@ -65,7 +65,8 @@ class Hermes(object): self.grid = Grid.select_grid( self.options.domain_type, self.options.vertical_description, self.options.output_timestep_num, - self.options.auxiliar_files_path, self.options.inc_lat, self.options.inc_lon, self.options.centre_lat, + self.options.auxiliar_files_path, self.options.inc_lat, self.options.inc_lon, self.options.lat_orig, + self.options.lon_orig, self.options.n_lat, self.options.n_lon, self.options.centre_lat, self.options.centre_lon, self.options.west_boundary, self.options.south_boundary, self.options.inc_rlat, self.options.inc_rlon, self.options.lat_1, self.options.lat_2, self.options.lon_0, self.options.lat_0, self.options.nx, self.options.ny, self.options.inc_x, self.options.inc_y, self.options.x_0, diff --git a/hermesv3_gr/modules/emision_inventories/emission_inventory.py b/hermesv3_gr/modules/emision_inventories/emission_inventory.py index 2ce190dcce308fc5c53617f149a2d54b558551cd..ed0a8377db316da63c710b91b92c96c6f2d83557 100644 --- a/hermesv3_gr/modules/emision_inventories/emission_inventory.py +++ b/hermesv3_gr/modules/emision_inventories/emission_inventory.py @@ -314,28 +314,28 @@ class EmissionInventory(object): num += 1 pollutants = list(map(str, re.split(', |,|; |;| ', emission_inventory.pollutants))) - #MONTHLY + # MONTHLY try: # gridded temporal profile - p_month = emission_inventory.p_month.replace('', options.input_dir) + p_month = emission_inventory.p_month.replace('', options.data_path) except AttributeError: p_month = emission_inventory.p_month # WEEKLY try: # gridded temporal profile - p_week = emission_inventory.p_week.replace('', options.input_dir) + p_week = emission_inventory.p_week.replace('', options.data_path) except AttributeError: p_week = emission_inventory.p_week # DAILY try: # gridded temporal profile - p_day = emission_inventory.p_day.replace('', options.input_dir) + p_day = emission_inventory.p_day.replace('', options.data_path) except AttributeError: p_day = emission_inventory.p_day # HOURLY try: # gridded temporal profile - p_hour = emission_inventory.p_hour.replace('', options.input_dir) + p_hour = emission_inventory.p_hour.replace('', options.data_path) except AttributeError: p_hour = emission_inventory.p_hour diff --git a/hermesv3_gr/modules/emision_inventories/point_gfas_emission_inventory.py b/hermesv3_gr/modules/emision_inventories/point_gfas_emission_inventory.py index e9a4c8ec3e79fb4fe034c89af39bdf5e67910314..0eb27d300a8f419d2e22cf9153ccb1f528b966db 100755 --- a/hermesv3_gr/modules/emision_inventories/point_gfas_emission_inventory.py +++ b/hermesv3_gr/modules/emision_inventories/point_gfas_emission_inventory.py @@ -282,7 +282,8 @@ class PointGfasEmissionInventory(EmissionInventory): gdf[pollutant['name']] = aux * gdf['src_area'] # print 'masa {0}: {1} '.format(pollutant['name'], gdf[pollutant['name']].sum()) - gdf[pollutant['name']] = (aux / gdf['dst_area']) * netcdf.variables['cell_area'][:].flatten()[gdf['src_index']] + gdf[pollutant['name']] = (aux / gdf['dst_area']) * \ + netcdf.variables['cell_area'][:].flatten()[gdf['src_index']] # print netcdf.variables['bc'][:].sum() netcdf.close() diff --git a/hermesv3_gr/modules/grids/grid.py b/hermesv3_gr/modules/grids/grid.py index 9263e64ff8c78d0db1737186a493fd87cf3401a9..81c4dfd418cb6904e346809134dfd57df5979b7c 100644 --- a/hermesv3_gr/modules/grids/grid.py +++ b/hermesv3_gr/modules/grids/grid.py @@ -94,8 +94,8 @@ class Grid(object): return grid @staticmethod - def select_grid(grid_type, vertical_description_path, timestep_num, temporal_path, inc_lat, inc_lon, - centre_lat, centre_lon, west_boundary, south_boundary, inc_rlat, inc_rlon, + def select_grid(grid_type, vertical_description_path, timestep_num, temporal_path, inc_lat, inc_lon, lat_orig, + lon_orig, n_lat, n_lon, centre_lat, centre_lon, west_boundary, south_boundary, inc_rlat, inc_rlon, lat_1, lat_2, lon_0, lat_0, nx, ny, inc_x, inc_y, x_0, y_0, lat_ts): # TODO describe better the rotated parameters """ @@ -182,6 +182,10 @@ class Grid(object): from hermesv3_gr.modules.grids.grid_global import GlobalGrid grid = GlobalGrid(grid_type, vertical_description_path, timestep_num, temporal_path, inc_lat, inc_lon) + elif grid_type == 'regular': + from hermesv3_gr.modules.grids.grid_latlon import LatLonGrid + grid = LatLonGrid(grid_type, vertical_description_path, timestep_num, temporal_path, inc_lat, inc_lon, + lat_orig, lon_orig, n_lat, n_lon) elif grid_type == 'rotated': from hermesv3_gr.modules.grids.grid_rotated import RotatedGrid grid = RotatedGrid(grid_type, vertical_description_path, timestep_num, temporal_path, @@ -200,7 +204,7 @@ class Grid(object): settings.write_log('ERROR: Check the .err file to get more info.') if settings.rank == 0: raise NotImplementedError("The grid type {0} is not implemented.".format(grid_type) - + " Use 'global', 'rotated' or 'lcc'.") + + " Use 'global', 'regular, 'rotated', 'lcc' or 'mercator.") sys.exit(1) settings.write_time('Grid', 'select_grid', timeit.default_timer() - st_time, level=3) @@ -411,6 +415,7 @@ class Grid(object): if settings.rank == 0: if not os.path.exists(self.shapefile_path): os.makedirs(self.shapefile_path) + settings.comm.Barrier() if full_grid: self.shapefile_path = os.path.join(self.shapefile_path, 'grid_shapefile.shp') else: @@ -428,7 +433,7 @@ class Grid(object): x = self.boundary_longitudes # sys.exit() - if self.grid_type == 'global': + if self.grid_type in ['global', 'regular']: x = x.reshape((x.shape[1], x.shape[2])) y = y.reshape((y.shape[1], y.shape[2])) @@ -531,6 +536,7 @@ class Grid(object): settings.write_log('\t\tGrid shapefile already done. Lets try to read it.', level=3) gdf = gpd.read_file(self.shapefile_path) + settings.comm.Barrier() settings.write_time('Grid', 'to_shapefile', timeit.default_timer() - st_time, level=1) return gdf diff --git a/hermesv3_gr/modules/grids/grid_latlon.py b/hermesv3_gr/modules/grids/grid_latlon.py new file mode 100644 index 0000000000000000000000000000000000000000..21b28abb3f390358b8e053cd271f0b1d2ede65d9 --- /dev/null +++ b/hermesv3_gr/modules/grids/grid_latlon.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python + +# Copyright 2018 Earth Sciences Department, BSC-CNS +# +# This file is part of HERMESv3_GR. +# +# HERMESv3_GR is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# HERMESv3_GR is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with HERMESv3_GR. If not, see . + + +import os +import sys +import timeit + +import hermesv3_gr.config.settings as settings +from grid import Grid + + +class LatLonGrid(Grid): + """ + Regional regular lat-lon grid object that contains all the information to do a global output. + + :param grid_type: Type of the output grid [global, rotated, lcc, mercator]. + :type grid_type: str + + :param vertical_description_path: Path to the file that contains the vertical description. + :type vertical_description_path: str + + :param timestep_num: Number of timesteps. + :type timestep_num: int + + :param temporal_path: Path to the temporal folder. + :type temporal_path: str + + :param inc_lat: Increment between latitude centroids. + :type inc_lat: float + + :param inc_lon: Increment between longitude centroids. + :type inc_lon: float + + :param lat_orig: Location of the latitude of the corner of the first cell (down left). + :type lat_orig: float + + :param lon_orig: Location of the longitude of the corner of the first cell (down left). + :type lon_orig: float + + :param n_lat: Number of cells on the latitude direction. + :type n_lat = int + + :param n_lon: Number of cells on the latitude direction. + :type n_lon = int + + """ + + def __init__(self, grid_type, vertical_description_path, timestep_num, temporal_path, inc_lat, inc_lon, lat_orig, + lon_orig, n_lat, n_lon): + import ESMF + + st_time = timeit.default_timer() + settings.write_log('\tCreating Regional regular lat-lon grid.', level=2) + + # Initialize the class using parent + super(LatLonGrid, self).__init__(grid_type, vertical_description_path, temporal_path) + + self.inc_lat = inc_lat + self.inc_lon = inc_lon + self.lat_orig = lat_orig + self.lon_orig = lon_orig + self.n_lat = n_lat + self.n_lon = n_lon + + self.crs = {'init': 'epsg:4326'} + self.create_coords() + + if not os.path.exists(self.coords_netcdf_file): + if settings.rank == 0: + self.write_coords_netcdf() + settings.comm.Barrier() + + self.esmf_grid = self.create_esmf_grid_from_file(self.coords_netcdf_file, sphere=False) + + self.x_lower_bound = self.esmf_grid.lower_bounds[ESMF.StaggerLoc.CENTER][1] + self.x_upper_bound = self.esmf_grid.upper_bounds[ESMF.StaggerLoc.CENTER][1] + self.y_lower_bound = self.esmf_grid.lower_bounds[ESMF.StaggerLoc.CENTER][0] + self.y_upper_bound = self.esmf_grid.upper_bounds[ESMF.StaggerLoc.CENTER][0] + + self.shape = (timestep_num, len(self.vertical_description), self.x_upper_bound-self.x_lower_bound, + self.y_upper_bound-self.y_lower_bound) + settings.comm.Barrier() + + total_area = self.get_cell_area() + self.full_shape = (timestep_num, len(self.vertical_description), total_area.shape[-2], total_area.shape[-1]) + self.cell_area = total_area[self.x_lower_bound:self.x_upper_bound, self.y_lower_bound:self.y_upper_bound] + + settings.write_time('LatLonGrid', 'Init', timeit.default_timer() - st_time, level=1) + + def create_coords(self): + """ + Create the coordinates for a global domain. + """ + import numpy as np + + st_time = timeit.default_timer() + settings.write_log('\t\tCreating global coordinates', level=3) + + # From corner latitude /longitude to center ones + lat_c_orig = self.lat_orig + (self.inc_lat / 2) + lon_c_orig = self.lon_orig + (self.inc_lon / 2) + + self.center_latitudes = np.arange(lat_c_orig, lat_c_orig + self.inc_lat * self.n_lat, self.inc_lat, + dtype=np.float) + boundary_latitudes = self.create_bounds(self.center_latitudes, self.inc_lat) + + # ===== Longitudes ===== + self.center_longitudes = np.arange(lon_c_orig, lon_c_orig + self.inc_lon * self.n_lon, self.inc_lon, + dtype=np.float) + if len(self.center_longitudes)//2 < settings.size: + settings.write_log('ERROR: Check the .err file to get more info.') + if settings.rank == 0: + raise AttributeError("ERROR: Maximum number of processors exceeded. " + + "It has to be less or equal than {0}.".format(len(self.center_longitudes)//2)) + sys.exit(1) + boundary_longitudes = self.create_bounds(self.center_longitudes, self.inc_lon) + + self.boundary_latitudes = boundary_latitudes.reshape((1,) + boundary_latitudes.shape) + self.boundary_longitudes = boundary_longitudes.reshape((1,) + boundary_longitudes.shape) + + settings.write_time('LatLonGrid', 'create_coords', timeit.default_timer() - st_time, level=2) + + +if __name__ == '__main__': + pass diff --git a/hermesv3_gr/modules/temporal/temporal.py b/hermesv3_gr/modules/temporal/temporal.py index 462380db124cf3eb7faa58a506a79a6b03da3393..9ebb759cd66424d9c50012e319432c1432e6f2ed 100644 --- a/hermesv3_gr/modules/temporal/temporal.py +++ b/hermesv3_gr/modules/temporal/temporal.py @@ -198,11 +198,12 @@ class TemporalDistribution(object): def get_gridded_temporal_profile(self, profile_value, profile_path): from netCDF4 import Dataset nc_in = Dataset(profile_path, mode='r') - if nc_in.dimensions['latitude'].size * nc_in.dimensions['longitude'].size != self.grid.full_shape[-2] * self.grid.full_shape[-1]: + if nc_in.dimensions['latitude'].size * nc_in.dimensions['longitude'].size != self.grid.full_shape[-2] * \ + self.grid.full_shape[-1]: settings.write_log('ERROR: Check the .err file to get more info.') if settings.rank == 0: - raise IOError('ERROR: The temporal gridded profile {0} is not in the destiny resolution like {1}.'.format( - profile_path, self.grid.coords_netcdf_file)) + raise IOError('ERROR: The temporal gridded profile {0} '.format(profile_path) + + 'is not in the destiny resolution like {1}.'.format(self.grid.coords_netcdf_file)) sys.exit(1) try: @@ -470,70 +471,6 @@ class TemporalDistribution(object): return profile - # def calculate_ending_date(self): - # """ - # Calculate the date of the last timestep. - # - # :return: Date of the last timestep - # :rtype: datetime.datetime - # """ - # from datetime import timedelta - # - # st_time = timeit.default_timer() - # - # if self.timestep_type == 'hourly': - # end_date = self.starting_date + (self.timestep_num - 1) * timedelta(hours=self.timestep_freq) - # elif self.timestep_type == 'daily': - # end_date = self.starting_date + (self.timestep_num - 1) * timedelta(hours=self.timestep_freq * 24) - # elif self.timestep_type == 'monthly': - # delta_year = (self.timestep_num - 1) * self.timestep_freq // 12 - # delta_month = (self.timestep_num - 1) * self.timestep_freq % 12 - # end_date = self.starting_date.replace(year=self.starting_date.year + delta_year, - # month=self.starting_date.month + delta_month) - # elif self.timestep_type == 'yearly': - # delta_year = (self.timestep_num - 1) * self.timestep_freq - # end_date = self.starting_date.replace(year=self.starting_date.year + delta_year) - # else: - # end_date = self.starting_date - # - # settings.write_time('TemporalDistribution', 'calculate_ending_date', timeit.default_timer() - st_time, level=3) - # - # return end_date - # - # def calculate_timedelta(self, date): - # """ - # Calculate the difference of time to the next timestep. - # - # :param date: Date of the current timestep. - # :type date: datetime.datetime - # - # :return: Difference of time to the next timestep. - # :rtype: datetime.timedelta - # """ - # from datetime import timedelta - # from calendar import monthrange, isleap - # - # st_time = timeit.default_timer() - # - # if self.timestep_type == 'hourly': - # delta = timedelta(hours=self.timestep_freq) - # elif self.timestep_type == 'daily': - # delta = timedelta(hours=self.timestep_freq * 24) - # elif self.timestep_type == 'monthly': - # days = monthrange(date.year, date.month)[1] - # delta = timedelta(hours=days * 24) - # elif self.timestep_type == 'yearly': - # if isleap(date.year): - # delta = timedelta(hours=366 * 24) - # else: - # delta = timedelta(hours=365 * 24) - # else: - # delta = None - # - # settings.write_time('TemporalDistribution', 'calculate_ending_date', timeit.default_timer() - st_time, level=3) - # - # return delta - def get_tz_from_id(self, tz_id): """ Extract the timezone (string format) for the given id (int). @@ -902,107 +839,6 @@ class TemporalDistribution(object): level=3) return factors - # def get_temporal_hourly_profile(self, profile_id, date=None): - # """ - # Extract the hourly profile of the given ID in a dictionary format. - # - # The hour (0 to 23) is the key (int) and the value (float) is the factor. - # - # :param profile_id: ID of the hourly profile to use. - # :type profile_id: str - # - # :param date: Date of the timestep to simulate. Not necessary for a single ID. - # :type date: datetime.datetime - # - # :return: Hourly profile where the hour (0 to 23) is the key (int) and the value (float) is the factor. - # :rtype: dict - # """ - # import pandas as pd - # - # st_time = timeit.default_timer() - # if date is None: - # df = pd.read_csv(self.hourly_profile_path) - # try: - # profile = df.loc[df[df.TP_H == profile_id].index[0]].to_dict() - # except IndexError: - # settings.write_log('ERROR: Check the .err file to get more info.') - # if settings.rank == 0: - # raise AttributeError('ERROR: Hourly profile ID {0} is not in the {1} file.'.format( - # profile_id, self.hourly_profile_path)) - # sys.exit(1) - # profile.pop('TP_H', None) - # profile = {int(k): float(v) for k, v in profile.items()} - # else: - # profile = None - # settings.write_time('TemporalDistribution', 'get_temporal_hourly_profile', timeit.default_timer() - st_time, - # level=3) - # - # return profile - # - # def get_temporal_weekly_profile(self, date): - # """ - # Extract the daily profile of the given ID in a dictionary format. - # - # The weekday (0 to 6) is the key (int) and the value (float) is the factor. - # - # :param date: Date of the timestep to simulate. - # :type date: datetime.datetime - # - # :return: Daily profile where the weekday (0 to 6) is the key (int) and the value (float) is the factor. - # :rtype: dict - # """ - # import pandas as pd - # - # st_time = timeit.default_timer() - # - # if self.weekly_profile_id is not None: - # df = pd.read_csv(self.weekly_profile_path) - # try: - # profile = df.loc[df[df.TP_W == self.weekly_profile_id].index[0]].to_dict() - # except IndexError: - # settings.write_log('ERROR: Check the .err file to get more info.') - # if settings.rank == 0: - # raise AttributeError('ERROR: Daily profile ID {0} is not in the {1} file.'.format( - # self.weekly_profile_id, self.weekly_profile_path)) - # sys.exit(1) - # profile.pop('TP_W', None) - # profile_aux = {int(k): float(v) for k, v in profile.items()} - # rebalance_factor = self.calculate_rebalance_factor(profile_aux, date) - # profile = {int(k): float(v) + rebalance_factor for k, v in profile.items()} - # else: - # profile = None - # - # settings.write_time('TemporalDistribution', 'get_temporal_weekly_profile', timeit.default_timer() - st_time, - # level=3) - # - # return profile - # - # def calculate_rebalance_factor(self, profile, date): - # """ - # Calculate the necessary factor make consistent the full month data. - # - # This is needed for the months that if you sum the daily factor of each day of the month it doesn't sum as - # the number of days of the month. - # - # :param profile: Daily profile. - # :type profile: dict - # - # :param date: Date of the timestep to simulate. - # :type date: datetime.datetime - # - # :return: Rebalance factor to be sum to the daily factor. - # :rtype: float - # """ - # st_time = timeit.default_timer() - # - # weekdays = self.calculate_weekdays(date) - # rebalance_factor = self.calculate_weekday_factor(profile, weekdays) - # - # settings.write_time('TemporalDistribution', 'calculate_rebalance_factor', timeit.default_timer() - st_time, - # level=3) - # - # return rebalance_factor - @staticmethod def calculate_weekday_factor(profile, weekdays): # TODO Documentation diff --git a/hermesv3_gr/modules/vertical/vertical_gfas.py b/hermesv3_gr/modules/vertical/vertical_gfas.py index 57da2327585957651f5d0f6e38bba9d0e2fe4a5a..309092613d01be5355d7ad8f21ced18110aaa288 100644 --- a/hermesv3_gr/modules/vertical/vertical_gfas.py +++ b/hermesv3_gr/modules/vertical/vertical_gfas.py @@ -54,7 +54,6 @@ class GfasVerticalDistribution(VerticalDistribution): return string - @staticmethod def calculate_widths(heights_list): """ diff --git a/hermesv3_gr/modules/writing/writer_monarch.py b/hermesv3_gr/modules/writing/writer_monarch.py index 3321b06c0f0945da74668f8e8d50d6c6bb503663..8749ed5c9f245d4316b62ed3509977d17d634ea0 100644 --- a/hermesv3_gr/modules/writing/writer_monarch.py +++ b/hermesv3_gr/modules/writing/writer_monarch.py @@ -127,7 +127,7 @@ class WriterMonarch(Writer): RegularLatLon = False Rotated = False LambertConformalConic = False - if self.grid.grid_type == 'global': + if self.grid.grid_type == 'global' or self.grid.grid_type == 'regular': RegularLatLon = True elif self.grid.grid_type == 'rotated': Rotated = True @@ -369,8 +369,8 @@ class WriterMonarch(Writer): # Rotated pole mapping = netcdf.createVariable('rotated_pole', 'c') mapping.grid_mapping_name = 'rotated_latitude_longitude' - mapping.grid_north_pole_latitude = self.grid.new_pole_latitude_degrees - mapping.grid_north_pole_longitude = 90 - self.grid.new_pole_longitude_degrees + mapping.grid_north_pole_latitude = 90 - self.grid.new_pole_latitude_degrees + mapping.grid_north_pole_longitude = self.grid.new_pole_longitude_degrees elif LambertConformalConic: # CRS mapping = netcdf.createVariable('Lambert_conformal', 'i') @@ -428,7 +428,7 @@ class WriterMonarch(Writer): rotated = False lcc = False - if self.grid.grid_type == 'global': + if self.grid.grid_type == 'global' or self.grid.grid_type == 'regular': regular_latlon = True elif self.grid.grid_type == 'rotated': rotated = True diff --git a/hermesv3_gr/tools/netcdf_tools.py b/hermesv3_gr/tools/netcdf_tools.py index f0d72dede20951049303d4de871368074ac39090..955468ed7fa610be247a54e718c96628bbe11e4e 100644 --- a/hermesv3_gr/tools/netcdf_tools.py +++ b/hermesv3_gr/tools/netcdf_tools.py @@ -271,7 +271,6 @@ def write_netcdf(netcdf_path, center_latitudes, center_longitudes, data_list, if boundary_longitudes is not None: lons.bounds = "lon_bnds" lon_bnds = netcdf.createVariable('lon_bnds', 'f', lon_dim + ('nv',), zlib=True) - # print lon_bnds[:].shape, boundary_longitudes.shape lon_bnds[:] = boundary_longitudes if rotated: