示例#1
0
 def test_fetch_prmsl(self):
     with patch.object(subprocess, 'call', return_value=0) as mock_method:
         twcr.fetch('prmsl',
                    datetime.datetime(1969, 3, 12),
                    version=version)
     remote_dir = ("http://portal.nersc.gov/project/20C_Reanalysis/" +
                   "20C_Reanalysis_version2c_ensemble/")
     remote_file = "%s/analysis/prmsl/prmsl_1969.nc" % remote_dir
     local_dir = "%s/20CR/version_%s/" % (os.environ['SCRATCH'], version)
     local_file = "%s/1969/prmsl.nc" % local_dir
     mock_method.assert_called_once_with("wget -O %s %s" %
                                         (local_file, remote_file),
                                         shell=True)
#!/usr/bin/env python

# Download the scout 0.0.2 data for the year of the flood

# Do the data extraction on Cori before running these retrievals

# Set up the NERSC ssh proxy before running these retrievals
#  ~/bin/sshproxy.sh -u pbrohan
# Otherwise each retrieval will request a password

import IRData.twcr as twcr
import datetime

for month in (10, 11, 12):
    try:
        twcr.fetch("observations", datetime.datetime(1930, month, 1), version="0.0.2")
        twcr.fetch("PRMSL", datetime.datetime(1930, month, 1), version="0.0.2")
        twcr.fetch("PRATE", datetime.datetime(1930, month, 1), version="0.0.2")
        twcr.fetch("TMP2m", datetime.datetime(1930, month, 1), version="0.0.2")
        twcr.fetch("TMPS", datetime.datetime(1930, month, 1), version="0.0.2")
        twcr.fetch("PWAT", datetime.datetime(1930, month, 1), version="0.0.2")
        twcr.fetch("WEASD", datetime.datetime(1930, month, 1), version="0.0.2")
        twcr.fetch("UGRND10m", datetime.datetime(1930, month, 1), version="0.0.2")
        twcr.fetch("VGRND10m", datetime.datetime(1930, month, 1), version="0.0.2")
    except:
        print("Failed retrieval for 1930-%02d" % month)

for month in (1, 2, 3, 4, 5, 6, 7, 8, 9):
    try:
        twcr.fetch("observations", datetime.datetime(1931, month, 1), version="0.0.2")
        twcr.fetch("PRMSL", datetime.datetime(1931, month, 1), version="0.0.2")
示例#3
0
#!/usr/bin/env python

import IRData.twcr as twcr
import datetime

for month in (4, 5, 6, 7, 8):
    dtn = datetime.datetime(1947, month, 1)
    twcr.fetch('prmsl', dtn, version='4.5.1')
示例#4
0
 def test_fetch_mslp(self):
     with self.assertRaises(Exception) as cm:
         twcr.fetch('mslp', datetime.datetime(1969, 3, 12), version=version)
     self.assertEqual("Unsupported variable mslp", str(cm.exception))
示例#5
0
#!/usr/bin/env python

import IRData.twcr as twcr
import datetime

dte = datetime.datetime(1905, 3, 1)
for version in (['4.5.1']):
    twcr.fetch('prmsl', dte, version=version)
    twcr.fetch_observations(dte, version=version)
示例#6
0
#!/usr/bin/env python

# We're going to work with 20CR2c prmsl fields.
# Retrieve the netCDF files from NERSC and store on $SCRATCH
# Modest quantity of data - 10 years for laptop work.

import datetime
import IRData.twcr as twcr

for year in range(1969, 1990):
    # 2c is in 1 year batches so month and day don't matter
    dte = datetime.datetime(year, 1, 1)
    twcr.fetch('prmsl', dte, version='2c')
    twcr.fetch('air.2m', dte, version='2c')
    twcr.fetch('prate', dte, version='2c')
    twcr.fetch('z500', dte, version='2c')
    twcr.fetch('uwnd.10m', dte, version='2c')
    twcr.fetch('vwnd.10m', dte, version='2c')
import datetime
import IRData.twcr as twcr

dte = datetime.datetime(1953, 2, 1)
twcr.fetch('prmsl', dte, version='2c')
twcr.fetch_observations(dte, version='2c')
示例#8
0
#!/usr/bin/env python

import datetime
import IRData.twcr as twcr

for var in ('prmsl', 'uwnd.10m', 'vwnd.10m', 'air.2m'):
    twcr.fetch(var, datetime.datetime(2009, 3, 12, 6), version='2c')
示例#9
0
#!/usr/bin/env python

# Download the scout 0.0.2 data for the year of the flood

# Do the data extraction on Cori before running these retrievals

# Set up the NERSC ssh proxy before running these retrievals
#  ~/bin/sshproxy.sh -u pbrohan
# Otherwise each retrieval will request a password

import IRData.twcr as twcr
import datetime

for month in (10, 11, 12):
    for var in ("observations", "PRMSL", "PRATE", "TMP2m", "TMPS", "PWAT",
                "WEASD", "UGRND10m", "VGRND10m"):
        try:
            twcr.fetch(var, datetime.datetime(1930, month, 1), version="0.0.1")
        except:
            print("Failed %s retrieval for 1930-%02d" % (var, month))

for month in (1, 2, 3, 4, 5, 6, 7, 8, 9):
    for var in ("observations", "PRMSL", "PRATE", "TMP2m", "TMPS", "PWAT",
                "WEASD", "UGRND10m", "VGRND10m"):
        try:
            twcr.fetch(var, datetime.datetime(1931, month, 1), version="0.0.1")
        except:
            print("Failed %s retrieval for 1931-%02d" % (var, month))
示例#10
0
#!/usr/bin/env python

# Download the 20CRv3 data for the period around the floods

import IRData.twcr as twcr
import datetime
import time

for year in range(1926, 1936):
    try:
        twcr.fetch("observations", datetime.datetime(year, 1, 1), version="3")
    except:
        time.sleep(300)
        twcr.fetch("observations", datetime.datetime(year, 1, 1), version="3")
    try:
        twcr.fetch("PRMSL", datetime.datetime(year, 1, 1), version="3")
    except:
        time.sleep(300)
        twcr.fetch("PRMSL", datetime.datetime(year, 1, 1), version="3")
    try:
        twcr.fetch("PRATE", datetime.datetime(year, 1, 1), version="3")
    except:
        time.sleep(300)
        twcr.fetch("PRATE", datetime.datetime(year, 1, 1), version="3")
    try:
        twcr.fetch("TMP2m", datetime.datetime(year, 1, 1), version="3")
    except:
        time.sleep(300)
        twcr.fetch("TMP2m", datetime.datetime(year, 1, 1), version="3")
    try:
        twcr.fetch("TMPS", datetime.datetime(year, 1, 1), version="3")
# Download the scout 4.6.7 data for the year of the flood

# Do the data extraction on Cori before running these retrievals

# Set up the NERSC ssh proxy before running these retrievals
#  ~/bin/sshproxy.sh -u pbrohan
# Otherwise each retrieval will request a password

import IRData.twcr as twcr
import datetime

for month in (10, 11, 12):
    try:
        twcr.fetch("observations",
                   datetime.datetime(1930, month, 1),
                   version="4.6.7")
        twcr.fetch("prmsl", datetime.datetime(1930, month, 1), version="4.6.7")
        twcr.fetch("prate", datetime.datetime(1930, month, 1), version="4.6.7")
        twcr.fetch("tmp",
                   datetime.datetime(1930, month, 1),
                   height=2,
                   version="4.6.7")
        twcr.fetch("uwnd.10m",
                   datetime.datetime(1930, month, 1),
                   version="4.6.7")
        twcr.fetch("vwnd.10m",
                   datetime.datetime(1930, month, 1),
                   version="4.6.7")
    except:
        print("Failed retrieval for 1930-%02" % month)
# Assemble local copies of some data to be used in Meteorographica examples.
#
# Uses IRData (http://brohan.org/IRData/) to get the data.

import datetime
import iris
import IRData.twcr as twcr
import pickle
import gzip

dte = datetime.datetime(1987, 10, 16, 6)
for var in ('prmsl', 'uwnd.10m', 'vwnd.10m', 'prate'):
    twcr.fetch(var, dte, version='2c')
    cube = twcr.load(var, dte, version='2c')
    fname = "20CR2c.%04d%02d%02d%02d.%s.nc" % (dte.year, dte.month, dte.day,
                                               dte.hour, var)
    #iris.save(cube,fname,netcdf_format='NETCDF4',
    #          zlib=True,complevel=9)
twcr.fetch_observations(dte, version='2c')
obs = twcr.load_observations_fortime(dte, version='2c')
f = gzip.open(
    "20CR2c.%04d%02d%02d%02d.observations.pklz" %
    (dte.year, dte.month, dte.day, dte.hour), "wb")
pickle.dump(obs, f)
f.close()
示例#13
0
#    try:
#        twcr.fetch("observations", datetime.datetime(1930, month, 1), version="4.6.1")
#        twcr.fetch("PRMSL", datetime.datetime(1930, month, 1), version="4.6.1")
#        twcr.fetch("PRATE", datetime.datetime(1930, month, 1), version="4.6.1")
#        twcr.fetch("TMP2m", datetime.datetime(1930, month, 1), version="4.6.1")
#        twcr.fetch("TMPS", datetime.datetime(1930, month, 1), version="4.6.1")
#        twcr.fetch("PWAT", datetime.datetime(1930, month, 1), version="4.6.1")
#        twcr.fetch("WEASD", datetime.datetime(1930, month, 1), version="4.6.1")
#        twcr.fetch("UGRND10m", datetime.datetime(1930, month, 1), version="4.6.1")
#        twcr.fetch("VGRND10m", datetime.datetime(1930, month, 1), version="4.6.1")
#    except:
#        print("Failed retrieval for 1930-%02d" % month)

for month in (1, 2, 3, 4, 5, 6, 7, 8, 9):
    try:
        #twcr.fetch("observations", datetime.datetime(1931, month, 1), version="4.6.1")
        twcr.fetch("PRMSL", datetime.datetime(1931, month, 1), version="4.6.1")
        twcr.fetch("PRATE", datetime.datetime(1931, month, 1), version="4.6.1")
        twcr.fetch("TMP2m", datetime.datetime(1931, month, 1), version="4.6.1")
        twcr.fetch("TMPS", datetime.datetime(1931, month, 1), version="4.6.1")
        twcr.fetch("PWAT", datetime.datetime(1931, month, 1), version="4.6.1")
        twcr.fetch("WEASD", datetime.datetime(1931, month, 1), version="4.6.1")
        twcr.fetch("UGRND10m",
                   datetime.datetime(1931, month, 1),
                   version="4.6.1")
        twcr.fetch("VGRND10m",
                   datetime.datetime(1931, month, 1),
                   version="4.6.1")
    except Exception:
        print("Failed retrieval for 1931-%02d" % month)
#!/usr/bin/env python

import IRData.twcr as twcr
import datetime

dte=datetime.datetime(1902,8,1)
for version in (['4.5.1']):
    twcr.fetch('prmsl',dte,version=version)
    twcr.fetch('air.2m',dte,version=version)
    twcr.fetch('tmp',dte,level=925,version=version)
    twcr.fetch_observations(dte,version=version)

示例#15
0
#!/usr/bin/env python

# Retrieve all the v3 observations files from NERSC

import datetime
import IRData.twcr as twcr

for year in range(1836,2016):
    twcr.fetch('observations',datetime.datetime(year,1,1),version='3')
示例#16
0
#!/usr/bin/env python

import IRData.twcr as twcr
import datetime

dte = datetime.datetime(1902, 6, 1)

#twcr.fetch('observations',dte,version='4.5.1')
#twcr.fetch('prmsl',dte,version='4.5.1')
#twcr.fetch('air.2m',dte,version='4.5.1')

twcr.fetch('observations', dte, version='4.6.1')
twcr.fetch('prmsl', dte, version='4.6.1')
twcr.fetch('air.2m', dte, version='4.6.1')