This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
8 changed files
with
103 additions
and
23 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
- "3.6" | ||
#- "3.6" | ||
os: | ||
- linux | ||
# - osx | ||
|
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
import tempfile | ||
from pywps import configuration | ||
|
||
import logging | ||
LOGGER = logging.getLogger('PYWPS') | ||
|
||
# init climaf | ||
os.environ['CLIMAF_CACHE'] = os.path.join(tempfile.gettempdir(), 'climaf_cache') | ||
# os.environ['CLIMAF_LOG_DIR'] = tempfile.gettempdir() | ||
|
||
from climaf.api import ds | ||
from climaf.dataloc import dataloc | ||
|
||
|
||
def search_cmip5(model=None, experiment=None, ensemble=None, variable=None, start_year=1980, end_year=1981): | ||
model = model or 'HadGEM2-ES' | ||
experiment = experiment or 'historical' | ||
ensemble = ensemble or 'r1i1p1' | ||
variable = variable or 'tas' | ||
# Set data location to CMIP5 archive on local file system | ||
cmip5_path = configuration.get_config_value("data", "archive_root") | ||
LOGGER.info("CMIP5 data path: %s", cmip5_path) | ||
dataloc(project="CMIP5", organization="CMIP5_DRS", url=[cmip5_path]) | ||
# Define a dataset selection from the CMIP5 project, using user inputs | ||
dset = ds(project='CMIP5', model=model, experiment=experiment, frequency='monthly', | ||
variable=variable, period='{}-{}'.format(start_year, end_year)) | ||
files = dset.baseFiles() | ||
if files: | ||
result = files.split()[0] | ||
else: | ||
result = None | ||
return result |
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 |
---|---|---|
|
@@ -14,5 +14,7 @@ dependencies: | |
- python-cdo | ||
- numpy | ||
- netcdf4 | ||
# search | ||
- climaf # python 2.7 only | ||
# tests | ||
- 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
$ /usr/bin/cdo remapbil,./grid_files/ll0.5deg_AFR-44i.nc -select,name=tasmin /badc/cordex/data/cordex/output/AFR-44/MOHC/ECMWF-ERAINT/evaluation/r1i1p1/MOHC-HadRM3P/v1/mon/tasmin/v20131211/tasmin_AFR-44_ECMWF-ERAINT_evaluation_r1i1p1_MOHC-HadRM3P_v1_mon_199001-199012.nc OUT/0.5_deg/tasmin_AFR-44_ECMWF-ERAINT_evaluation_r1i1p1_MOHC-HadRM3P_v1_mon_199001-199012.nc | ||
|
||
cdo(2) select: Process started | ||
cdo remapbil: Bilinear weights from lonlat (194x201) to lonlat (173x179) grid | ||
cdo(2) select: Processed 467928 values from 1 variable over 12 timesteps | ||
cdo remapbil: Processed 467928 values from 1 variable over 12 timesteps [0.20s 20MB] | ||
|
||
$ ncdump -h /badc/cordex/data/cordex/output/AFR-44/MOHC/ECMWF-ERAINT/evaluation/r1i1p1/MOHC-HadRM3P/v1/mon/tasmin/v20131211/tasmin_AFR-44_ECMWF-ERAINT_evaluation_r1i1p1_MOHC-HadRM3P_v1_mon_199001-199012.nc | head -6 | ||
|
||
netcdf tasmin_AFR-44_ECMWF-ERAINT_evaluation_r1i1p1_MOHC-HadRM3P_v1_mon_199001-199012 { | ||
dimensions: | ||
time = UNLIMITED ; // (12 currently) | ||
lat = 201 ; | ||
lon = 194 ; | ||
bnds = 2 ; | ||
|
||
$ ncdump -h OUT/0.5_deg/tasmin_AFR-44_ECMWF-ERAINT_evaluation_r1i1p1_MOHC-HadRM3P_v1_mon_199001-199012.nc | head -6 | ||
|
||
netcdf tasmin_AFR-44_ECMWF-ERAINT_evaluation_r1i1p1_MOHC-HadRM3P_v1_mon_199001-199012 { | ||
dimensions: | ||
time = UNLIMITED ; // (12 currently) | ||
bnds = 2 ; | ||
lon = 173 ; |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import pytest | ||
|
||
from c4cds import search | ||
|
||
|
||
@pytest.mark.data | ||
def test_search_cmip5(): | ||
assert 'tas_Amon_HadGEM2-ES_historical_r1i1p1_195912-198411.nc' in search.search_cmip5( | ||
model='HadGEM2-ES', | ||
experiment='historical', | ||
variable='tas', | ||
start_year=1971, | ||
end_year=1980 | ||
) |