Created
March 29, 2019 03:16
-
-
Save ScottWales/e06dd10858bf64ff8d43655ab3183381 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import netCDF4 | |
import glob | |
import multiprocessing | |
path = '/g/data/rr3/publications/CMIP5/output1/CSIRO-BOM/ACCESS1-3/rcp85/day/atmos/day/r1i1p1/latest/tas/*.nc' | |
path = '/g/data/ub4/era5/netcdf/surface/2T/199?/*.nc' | |
def process(p): | |
d = netCDF4.Dataset(p) | |
try: | |
m = d['t2m'][0:300,...].mean() | |
except Exception as e: | |
m = repr(e) | |
d.close() | |
return p, m | |
with multiprocessing.Pool(4) as p: | |
for r in p.imap_unordered(process, glob.glob(path)): | |
print(r) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment