Commit 2c5c2925 authored by Javier Vegas-Regidor's avatar Javier Vegas-Regidor
Browse files

Merge branch 'master' into 'production'

Master

See merge request !55
parents f5c74aa7 de3d96ad
......@@ -26,21 +26,21 @@ test_python2:
- source activate earthdiagnostics2
- python run_test.py
test_python3:
stage: test
script:
- git submodule sync --recursive
- git submodule update --init --recursive
- conda env update -f environment.yml -n earthdiagnostics3 python=3.6
- source activate earthdiagnostics3
- python run_test.py
#test_python3:
# stage: test
# script:
# - git submodule sync --recursive
# - git submodule update --init --recursive
# - conda env update -f environment.yml -n earthdiagnostics3 python=3.6
# - source activate earthdiagnostics3
# - python run_test.py
report_codacy:
stage: report
script:
- source activate earthdiagnostics3
- pip install codacy-coverage --upgrade
- python-codacy-coverage -r test/report/python3/coverage.xml
- python-codacy-coverage -r test/report/python2/coverage.xml
clean:
stage: clean
......
3.0.0rc10
3.0.0rc11
......@@ -5,8 +5,8 @@ import os
import shutil
import uuid
import traceback
import pygrib
from datetime import datetime
import eccodes
from datetime import datetime, timedelta
import six
from bscearth.utils.date import parse_date, chunk_end_date, previous_day, date2str, add_months
......@@ -352,16 +352,19 @@ class Cmorizer(object):
def _get_atmos_timestep(self, gribfile):
Log.info('Getting timestep...')
grib_handler = pygrib.open(gribfile)
dates = set()
for mes in grib_handler:
dates.add(mes.validDate)
with eccodes.GribFile(gribfile) as grib:
dates = set()
for mes in grib:
try:
dates.add(mes['validDate'])
except Exception:
dates.add(parse_date(str(mes['date'])) + timedelta(hours=int(mes['stepRange'])))
print(dates)
dates = list(dates)
dates.sort()
atmos_timestep = dates[1] - dates[0]
atmos_timestep = int(atmos_timestep.total_seconds() / 3600)
self.experiment.atmos_timestep = atmos_timestep
grib_handler.close()
return atmos_timestep
def _cmorize_nc_file(self, filename):
......
......@@ -145,7 +145,7 @@ class Siasiesiv(Diagnostic):
handler = Utils.open_cdf(self.sit.local_file)
handler.variables[self.sit_varname].coordinates = coordinates
handler.close()
sit = iris.load_cube(self.sic.local_file)
sit = iris.load_cube(self.sit.local_file)
for basin, mask in six.iteritems(self.masks):
self.results['siarean'][basin] = self.sum(sic, mask, north=True)
......
......@@ -11,14 +11,15 @@ dependencies:
- cdo=1.9.2
- nco
- python-cdo
- python-eccodes
- coverage
- pygrib
- psutil
- six
- cf_units
- openpyxl
# testing
- mock
- cmake
- coverage
- pytest
- pytest-cov
......@@ -30,5 +31,7 @@ dependencies:
- nco
- exrex
- xxhash
# testing
- pytest-profiling
- dummydata
import glob
import shutil
import os
import netCDF4
def main():
for path in glob.glob('/esarchive/exp/ecearth/a0pe/cmorfiles/BSC/EC-EARTH3/a0pe/*/day/*/*/*/*_Oday_*'):
day_path =path.replace('_OIday_', '_day_')
if os.path.isfile(day_path):
print('del {0}'.format(path))
os.remove(path)
else:
print('move {0}'.format(path))
handler = netCDF4.Dataset(path, 'a')
handler.table_id = "Table day (December 2013)"
handler.close()
shutil.move(path, day_path)
if __name__ == '__main__':
main()
......@@ -25,7 +25,7 @@ setup(
keywords=['climate', 'weather', 'diagnostic'],
setup_requires=['pyproj'],
install_requires=['numpy', 'netCDF4', 'bscearth.utils', 'cdo>=1.3.4', 'nco>=0.0.3', 'iris>=1.12.0', 'coverage',
'pygrib', 'openpyxl', 'mock', 'futures', 'cf_units', 'xxhash', 'six', 'psutil',
'openpyxl', 'mock', 'futures', 'xxhash', 'six', 'psutil', 'eccodes',
'exrex'],
packages=find_packages(),
include_package_data=True,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment