diff --git a/CHANGELOG b/CHANGELOG index 918d3d0914529fa2d32423733aa1e951f8e70ed5..7d4bbafa65b02f3ce2e21662713287f5f90fbc05 100755 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ 1.0.4 - XXXX/XX/XX + 2019/07/19 - Specified version on timezonefinder to be less than 4.0.0 (not further support to python 2.7.X) + - Solved bug on some grid creation that makes one cell more sometimes issue #23 + 1.0.3 2019/06/07 - Solved bug on WRF-Chem unit change diff --git a/conf/hermes.conf b/conf/hermes.conf index 06efd9765e1d6dcc523be5414b4b016641e40468..a9d139395600ea7e6bdb7c016f6b4d649469b192 100755 --- a/conf/hermes.conf +++ b/conf/hermes.conf @@ -30,31 +30,31 @@ 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 + #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 - #centre_lon = 20 + #centre_lat = 35.0 + #centre_lon = 20.0 #west_boundary = -51 #south_boundary = -35 #inc_rlat = 0.1 #inc_rlon = 0.1 # if domain_type == lcc: - #lat_1 = 37 - #lat_2 = 43 - #lon_0 = -3 - #lat_0 = 40 + #lat_1 = 37.0 + #lat_2 = 43.0 + #lon_0 = -3.0 + #lat_0 = 40.0 #nx = 478 #ny = 398 #inc_x = 12000 @@ -64,13 +64,13 @@ auxiliar_files_path = /data/auxiliar_files/_ # if domain_type == mercator: #lat_ts = -1.5 - #lon_0 = -18 + #lon_0 = -18.0 #nx = 210 #ny = 236 #inc_x = 50000 #inc_y = 50000 #x_0 = -126017.5 - #y_0 = -5407460 + #y_0 = -5407460.0 [EMISSION_INVENTORY_CONFIGURATION] diff --git a/hermesv3_gr/__init__.py b/hermesv3_gr/__init__.py index 976498ab9cacbd0ed9a538cebd482e5df53f8efb..92192eed4fc88eaee9fdbafbc8e2139c43ba00e2 100755 --- a/hermesv3_gr/__init__.py +++ b/hermesv3_gr/__init__.py @@ -1 +1 @@ -__version__ = "1.0.3" +__version__ = "1.0.4" diff --git a/hermesv3_gr/modules/grids/grid.py b/hermesv3_gr/modules/grids/grid.py index 81c4dfd418cb6904e346809134dfd57df5979b7c..ce1133bcb4df82e9b8b18004adcc6ef0e07d7ccc 100755 --- a/hermesv3_gr/modules/grids/grid.py +++ b/hermesv3_gr/modules/grids/grid.py @@ -318,7 +318,7 @@ class Grid(object): # Calculate the quantity of cells. n = (abs(boundary) / inc) * 2 # Calculate all the values - values = np.arange(origin + inc, origin + (n * inc) - inc + inc / 2, inc, dtype=np.float) + values = np.linspace(origin + inc, origin + ((n - 1) * inc), n - 1, dtype=np.float) settings.write_time('Grid', 'create_regular_grid_1d_array', timeit.default_timer() - st_time, level=3) @@ -450,7 +450,6 @@ class Grid(object): x_aux[:, :, 3] = x[np.newaxis, :, 0] x = x_aux - # print x del x_aux # y_aux = np.empty((x.shape[0], y.shape[0], 4)) @@ -465,7 +464,6 @@ class Grid(object): y_aux[:, :, 2] = y[:, np.newaxis, 1] y_aux[:, :, 3] = y[:, np.newaxis, 1] - # print y_aux y = y_aux del y_aux diff --git a/hermesv3_gr/modules/grids/grid_latlon.py b/hermesv3_gr/modules/grids/grid_latlon.py index 21b28abb3f390358b8e053cd271f0b1d2ede65d9..f66f80e1f963c8a2522b0cc4219a114365514f4c 100755 --- a/hermesv3_gr/modules/grids/grid_latlon.py +++ b/hermesv3_gr/modules/grids/grid_latlon.py @@ -117,19 +117,20 @@ class LatLonGrid(Grid): 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) + self.center_latitudes = np.linspace(lat_c_orig, lat_c_orig + (self.inc_lat * (self.n_lat - 1)), self.n_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) + self.center_longitudes = np.linspace(lon_c_orig, lon_c_orig + (self.inc_lon * (self.n_lon - 1)), self.n_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) diff --git a/hermesv3_gr/modules/grids/grid_lcc.py b/hermesv3_gr/modules/grids/grid_lcc.py index 321aebdcbf2ed796be7ffdfd80689a43049b454a..c0b4d4e3266d647d98df229ab480c4f931022dbb 100755 --- a/hermesv3_gr/modules/grids/grid_lcc.py +++ b/hermesv3_gr/modules/grids/grid_lcc.py @@ -175,14 +175,15 @@ class LccGrid(Grid): settings.write_log('\t\tCreating lcc coordinates', level=3) # Create a regular grid in metres (Two 1D arrays) - self.x = np.arange(self.x_0, self.x_0 + self.inc_x * self.nx, self.inc_x, dtype=np.float) + self.x = np.linspace(self.x_0, self.x_0 + (self.inc_x * (self.nx - 1)), self.nx, dtype=np.float) if len(self.x)//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.x)//2)) sys.exit(1) - self.y = np.arange(self.y_0, self.y_0 + self.inc_y * self.ny, self.inc_y, dtype=np.float) + + self.y = np.linspace(self.y_0, self.y_0 + (self.inc_y * (self.ny - 1)), self.ny, dtype=np.float) # 1D to 2D x = np.array([self.x] * len(self.y)) diff --git a/hermesv3_gr/modules/grids/grid_mercator.py b/hermesv3_gr/modules/grids/grid_mercator.py index 6a0f651bf7ad9e57e47150e4eb0117561271e48e..c715b8e4ba8d02b2362c6a7c09ff2bba03f4f453 100755 --- a/hermesv3_gr/modules/grids/grid_mercator.py +++ b/hermesv3_gr/modules/grids/grid_mercator.py @@ -164,14 +164,14 @@ class MercatorGrid(Grid): st_time = timeit.default_timer() # Create a regular grid in metres (Two 1D arrays) - self.x = np.arange(self.x_0, self.x_0 + self.inc_x * self.nx, self.inc_x, dtype=np.float) + self.x = np.linspace(self.x_0, self.x_0 + (self.inc_x * (self.nx - 1)), self.nx, dtype=np.float) if len(self.x)//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.x)//2)) sys.exit(1) - self.y = np.arange(self.y_0, self.y_0 + self.inc_y * self.ny, self.inc_y, dtype=np.float) + self.y = np.linspace(self.y_0, self.y_0 + (self.inc_y * (self.ny - 1)), self.ny, dtype=np.float) # 1D to 2D x = np.array([self.x] * len(self.y)) diff --git a/hermesv3_gr/tools/coordinates_tools.py b/hermesv3_gr/tools/coordinates_tools.py index 8dbc7cd496f0ea0ff1c9b92df8349599b0eea9ec..56d929adacdf4388307d2d307a46d17fcf57a53b 100755 --- a/hermesv3_gr/tools/coordinates_tools.py +++ b/hermesv3_gr/tools/coordinates_tools.py @@ -283,8 +283,8 @@ def create_regular_rotated(lat_origin, lon_origin, lat_inc, lon_inc, n_lat, n_lo """ import numpy as np - center_latitudes = np.arange(lat_origin, lat_origin + (n_lat*lat_inc), lat_inc, dtype=np.float) - center_longitudes = np.arange(lon_origin, lon_origin + (n_lon*lon_inc), lon_inc, dtype=np.float) + center_latitudes = np.linspace(lat_origin, lat_origin + (n_lat * (lat_inc - 1)), n_lat, dtype=np.float) + center_longitudes = np.linspace(lon_origin, lon_origin + (n_lon * (lon_inc - 1)), n_lon, dtype=np.float) corner_latitudes = create_bounds_esmpy(center_latitudes) corner_longitudes = create_bounds_esmpy(center_longitudes) @@ -292,88 +292,6 @@ def create_regular_rotated(lat_origin, lon_origin, lat_inc, lon_inc, n_lat, n_lo return center_latitudes, center_longitudes, corner_latitudes, corner_longitudes -def create_regular_old(lat_origin, lon_origin, lat_inc, lon_inc, n_lat, n_lon): - # TODO Documentation - import numpy as np - - center_latitudes = np.arange(lat_origin, lat_origin + (n_lat*lat_inc), lat_inc, dtype=np.float) - center_longitudes = np.arange(lon_origin, lon_origin + (n_lon*lon_inc), lon_inc, dtype=np.float) - - corner_latitudes = create_bounds(center_latitudes) - corner_longitudes = create_bounds(center_longitudes) - - return center_latitudes, center_longitudes, corner_latitudes, corner_longitudes - - -def create_regular_grid(center_lat, center_lon, west_boundary, south_boundary, inc_lat, inc_lon): - """ - Create a custom grid with the given parameters. The grid is divided in 4 arrays: - - Center Latitudes - - Center Longitudes - - Boundary Latitudes (# latitudes +1) - - Boundary Longitudes (# longitudes +1) - - :param center_lat: Latitude of the center of the grid (degrees). - :type center_lat: float - - :param center_lon: Longitude of the center of the grid (degrees). - :type center_lon: float - - :param west_boundary: Distance from de center to the western boundary (degrees) - (not to the center of the first cell) - :type west_boundary: float - - :param south_boundary: Distance from de center to the southern boundary (degrees) - (not to the center of the first cell) - :type south_boundary: float - - :param inc_lat: Vertical resolution of each cell (degrees). - :type inc_lat: float - - :param inc_lon: Horizontal resolution of each cell (degrees) - :type inc_lon: float - - :return: Arrays with the Center Latitudes, Center Longitudes, Boundary Latitudes, Boundary Longitudes. - :rtype: tuple (numpy.array, numpy.array, numpy.array, numpy.array) - """ - import numpy as np - - lat_origin = center_lat - abs(south_boundary) # + (inc_lat/2) - lon_origin = center_lon - abs(west_boundary) # + (inc_lon/2) - n_lat = (abs(south_boundary)/inc_lat)*2 - n_lon = (abs(west_boundary)/inc_lon)*2 - - center_latitudes = np.arange(lat_origin + inc_lat, lat_origin + (n_lat*inc_lat) - inc_lat + inc_lat / 2, inc_lat, - dtype=np.float) - center_longitudes = np.arange(lon_origin + inc_lon, lon_origin + (n_lon*inc_lon) - inc_lon + inc_lon / 2, inc_lon, - dtype=np.float) - - corner_latitudes = create_bounds(center_latitudes) - corner_longitudes = create_bounds(center_longitudes) - - center_latitudes = np.concatenate([ - [lat_origin + inc_lat / 2 - inc_lat / 4], - center_latitudes, - [lat_origin + (n_lat * inc_lat) - inc_lat / 2 + inc_lat / 4]]) - - center_longitudes = np.concatenate([ - [lon_origin + inc_lon / 2 - inc_lon / 4], - center_longitudes, - [lon_origin + (n_lon * inc_lon) - inc_lon / 2 + inc_lon / 4]]) - - corner_latitudes = np.concatenate([ - [[[lat_origin, lat_origin + inc_lat / 2]]], - corner_latitudes, - [[[lat_origin + (n_lat * inc_lat) - inc_lat / 2, lat_origin + (n_lat * inc_lat)]]]], axis=1) - - corner_longitudes = np.concatenate([ - [[[lon_origin, lon_origin + inc_lon / 2]]], - corner_longitudes, - [[[lon_origin + (n_lon * inc_lon) - inc_lon / 2, lon_origin + (n_lon * inc_lon)]]]], axis=1) - - return center_latitudes, center_longitudes, corner_latitudes, corner_longitudes - - if __name__ == '__main__': import numpy as np new_pole_lon_d = 20.0 # lonpole tlm0d