Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
djk2120 committed Jan 24, 2022
1 parent 4d0ddf5 commit 81c0025
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions ppe_tools/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
import matplotlib.pyplot as plt
import glob

#define the directory structure to find files
def get_files(name,htape,keys):
topdir = '/glade/scratch/djk2120/PPEn11/hist/'
thisdir = topdir+name+'/'
files = [glob.glob(thisdir+'*'+key+'*'+htape+'*.nc')[0] for key in keys]
return files

def get_ensemble(files,data_vars,keys,paramkey,p=True,extras=[]):

def preprocess(ds):
Expand Down Expand Up @@ -139,7 +146,7 @@ def get_lapft(la,sample_h1):
lapft.attrs['units'] = 'km2'
return lapft

def get_cfs(attrs,datavar):
def get_cfs(attrs,datavar,ds):
if datavar in attrs.index:
cf1 = attrs.cf1[datavar]
cf2 = attrs.cf2[datavar]
Expand Down Expand Up @@ -227,7 +234,7 @@ def gcell_mean(ens,datavar,la,attrs):
dvs = datavar.split('-')
ds = get_ensemble(files,dvs,keys,paramkey)

cf1,cf2,units = get_cfs(attrs,datavar)
cf1,cf2,units = get_cfs(attrs,datavar,ds)

x = ds[dvs[0]]
if len(dvs)==2:
Expand All @@ -246,7 +253,7 @@ def biome_mean(ens,datavar,la,attrs):
dvs = datavar.split('-')
ds = get_ensemble(files,dvs,keys,paramkey)

cf1,cf2,units = get_cfs(attrs,datavar)
cf1,cf2,units = get_cfs(attrs,datavar,ds)

x = ds[dvs[0]]
if len(dvs)==2:
Expand All @@ -266,7 +273,7 @@ def pft_mean(ens,datavar,la,attrs):
dvs = datavar.split('-')
ds = get_ensemble(files,dvs,keys,paramkey)

cf1,cf2,units = get_cfs(attrs,datavar)
cf1,cf2,units = get_cfs(attrs,datavar,ds)
lapft = get_lapft(la,files[0])

x = ds[dvs[0]]
Expand Down

0 comments on commit 81c0025

Please sign in to comment.