Skip to content

Commit

Permalink
Merge pull request #148 from brian-rose/data-path
Browse files Browse the repository at this point in the history
Change data paths to avoid THREDDS server
  • Loading branch information
brian-rose committed May 13, 2021
2 parents a9d9624 + 737320b commit 3ea369a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
7 changes: 4 additions & 3 deletions climlab/radiation/cam3/cam3.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@
from climlab.radiation.radiation import _Radiation_SW, _Radiation_LW
import os, warnings, pooch
import xarray as xr
from climlab.utils import _datapath_http


def init_cam3(mod):
# Initialise absorptivity / emissivity data
filename = 'abs_ems_factors_fastvx.c030508.nc'
remotepath_http = 'http://thredds.atmos.albany.edu:8080/thredds/fileServer/CLIMLAB/absorptivity/' + filename
filehandle = pooch.retrieve(url=remotepath_http, known_hash="261043a01b15ebb82ba2baa71311a6807ba9ea6d720baa15bc091f0e61b2a8f2")
remotepath_http = _datapath_http + 'absorptivity/abs_ems_factors_fastvx.c030508.nc'
filehandle = pooch.retrieve(url=remotepath_http,
known_hash="261043a01b15ebb82ba2baa71311a6807ba9ea6d720baa15bc091f0e61b2a8f2")
data = xr.open_dataset(filehandle)
# Populate storage arrays with values from netcdf file
for field in ['ah2onw', 'eh2onw', 'ah2ow', 'ln_ah2ow', 'cn_ah2ow', 'ln_eh2ow', 'cn_eh2ow']:
Expand Down
5 changes: 3 additions & 2 deletions climlab/radiation/radiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
from climlab.domain.field import Field
import os, warnings, pooch
import xarray as xr
from climlab.utils import _datapath_http


def default_specific_humidity(Tatm):
Expand Down Expand Up @@ -135,8 +136,8 @@ def default_absorbers(Tatm,
xTatm = Tatm.to_xarray()
O3 = 0. * xTatm
if ozone_file is not None:
remotepath_http = 'http://thredds.atmos.albany.edu:8080/thredds/fileServer/CLIMLAB/ozone/' + ozone_file
ozonefilehandle = pooch.retrieve(url=remotepath_http,
ozonepath_http = _datapath_http + 'ozone/' + ozone_file
ozonefilehandle = pooch.retrieve(url=ozonepath_http,
known_hash="bc659bfa129fafa4ed9368bb19278ae15724a5a66599affd317c143ba511ff84")
ozonedata = xr.open_dataset(ozonefilehandle)
## zonal and time average
Expand Down
9 changes: 5 additions & 4 deletions climlab/solar/orbital/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
import os, pooch
import pandas as pd
import xarray as xr
from climlab.utils import _datapath_http

# Two possible sources for the Berger and Loutre 1991 data table
NCDCpath = "https://www1.ncdc.noaa.gov/pub/data/paleo/climate_forcing/orbital_variations/insolation/orbit91"
threddspath = "http://thredds.atmos.albany.edu:8080/thredds/fileServer/CLIMLAB/orbital/orbit91"

# Possible sources for the Berger and Loutre 1991 data table
#NCDCpath = "https://www1.ncdc.noaa.gov/pub/data/paleo/climate_forcing/orbital_variations/insolation/orbit91"
path = _datapath_http + 'orbital/orbit91'

def _get_Berger_data(verbose=True):
'''Read in the Berger and Loutre orbital table as a pandas dataframe, convert to xarray
'''
path = threddspath
orbit91handle = pooch.retrieve(path,
known_hash="3afc20dda7b385bdd366bc4c9cf60be02d8defdb4c0f317430ca8386d62f81a3")
orbit91_pd = pd.read_csv(orbit91handle, delim_whitespace=True, skiprows=1, verbose=True)
Expand Down
5 changes: 5 additions & 0 deletions climlab/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
'''A collection of general purpose utility functions.'''

# Root URL for the climlab data repository
_datapath_http = "http://www.atmos.albany.edu/facstaff/brose/resources/climlab_data/"
# Alternate path that should also work
_threddspath_http = "http://thredds.atmos.albany.edu:8080/thredds/fileServer/CLIMLAB/"

0 comments on commit 3ea369a

Please sign in to comment.