-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
118 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
Developers | ||
========== | ||
|
||
* tscanlon <[email protected]> | ||
* wpreimes <[email protected]> | ||
* Tracy Scanlon <[email protected]> | ||
* Wolfgang Preimesberger <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,11 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from pygeogrids.grids import BasicGrid, CellGrid | ||
import numpy as np | ||
try: | ||
from smecv_grid.grid import SMECV_Grid_v042 | ||
except: | ||
import warnings | ||
warnings.warn('SMECV grid is not installed') | ||
from smecv_grid.grid import SMECV_Grid_v042 | ||
|
||
def C3SCellGrid(): | ||
''' | ||
Returns | ||
------- | ||
grid : CellGrid | ||
The global QDEG grid | ||
''' | ||
resolution = 0.25 | ||
lon, lat = np.meshgrid( | ||
np.arange(-180 + resolution / 2, 180 + resolution / 2, resolution), | ||
np.flipud(np.arange(-90 + resolution / 2, 90 + resolution / 2, resolution))) | ||
|
||
return BasicGrid(lon.flatten(), lat.flatten()).to_cell_grid(cellsize=5.) | ||
|
||
def C3SLandPoints(grid): | ||
''' | ||
Create a subset of land points. | ||
Returns | ||
------- | ||
points : np.array | ||
Points in the passed grid that are over land | ||
dist : np.array | ||
Distance between the reference land points and the next point in the | ||
passed grid. | ||
''' | ||
lg = SMECV_Grid_v042('land') | ||
lat = lg.get_grid_points()[2] | ||
lon = lg.get_grid_points()[1] | ||
|
||
points, dist = grid.find_nearest_gpi(lon, lat) | ||
|
||
return points, dist | ||
|
||
return SMECV_Grid_v042(None) | ||
|
||
def C3SLandGrid(): | ||
''' | ||
0.25deg cell grid of land points from c3s land mask. | ||
Returns | ||
------- | ||
landgrid : CellGrid | ||
The reduced QDEG grid | ||
''' | ||
grid = C3SCellGrid() | ||
land_gpis, dist = C3SLandPoints(grid) | ||
if any(dist) > 0: | ||
raise Exception('C3S grid does not conform with QDEG grid') | ||
return grid.subgrid_from_gpis(land_gpis) | ||
|
||
|
||
if __name__ == '__main__': | ||
grid = C3SCellGrid() | ||
shape = grid.get_grid_points()[0].size | ||
assert shape == 1036800 | ||
|
||
landpoints, dist = C3SLandPoints(grid) | ||
return SMECV_Grid_v042('land') | ||
|
||
land_grid = C3SLandGrid() | ||
shape = land_grid.get_grid_points()[0].size | ||
assert shape == 244243 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
|
||
.. include:: img2ts.rst | ||
|
||
.. include:: varnames.rst | ||
|
||
Contents | ||
======== | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Dummy conftest.py for c3s_sm_reader. | ||
Dummy conftest.py for c3s_sm. | ||
If you don't know what this is for, just leave it empty. | ||
Read more about conftest.py under: | ||
https://pytest.org/latest/plugins.html | ||
""" | ||
from __future__ import print_function, absolute_import, division | ||
|
||
import pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
def test_cell_grid(): | ||
pass | ||
from c3s_sm.grid import C3SCellGrid | ||
from c3s_sm.grid import C3SLandGrid | ||
import numpy as np | ||
|
||
|
||
def test_landgrid(): | ||
pass | ||
def test_C3SCellGrid(): | ||
grid = C3SCellGrid() | ||
gp, dist = grid.find_nearest_gpi(75.625, 14.625) | ||
assert gp == 602942 | ||
lon, lat = grid.gpi2lonlat(602942) | ||
assert lon == 75.625 | ||
assert lat == 14.625 | ||
assert np.where(grid.get_grid_points()[0] == 602942)[0][0] == 434462 # index | ||
assert grid.get_grid_points()[1][434462] == lon | ||
assert grid.get_grid_points()[2][434462] == lat | ||
assert grid.gpi2cell(602942) == 1856 | ||
assert grid.gpis.size == 1036800 | ||
assert grid.gpis[0] == 1035360 | ||
assert np.unique(grid.get_grid_points()[3]).size == 2592 | ||
|
||
|
||
def test_landgrid(): | ||
grid = C3SLandGrid() | ||
gp, dist = grid.find_nearest_gpi(75.625, 14.625) | ||
assert gp == 602942 | ||
lon, lat = grid.gpi2lonlat(602942) | ||
assert lon == 75.625 | ||
assert lat == 14.625 | ||
assert np.where(grid.get_grid_points()[0] == 602942)[0][0] == 177048 # index | ||
assert grid.get_grid_points()[1][177048] == lon | ||
assert grid.get_grid_points()[2][177048] == lat | ||
assert grid.gpi2cell(602942) == 1856 | ||
assert grid.gpis.size == 1036800 | ||
assert grid.activegpis.size == 244243 | ||
assert grid.gpis[0] == 1035360 | ||
assert grid.activegpis[0] == 999942 | ||
assert np.unique(grid.get_grid_points()[3]).size == 1001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters