Commit 8e0ac6f9 authored by Ingrid Luijkx's avatar Ingrid Luijkx
Browse files

Corrected reading in of may_reject and may_localize keys from...

Corrected reading in of may_reject and may_localize keys from sites_weights.rc, and option added to include only certain hours of the day (for obspack files containing hourly observations)
parent cb29d4ca
......@@ -133,7 +133,6 @@ class ObsPackObservations(Observation):
for idx, val in zip(ids, simulated):
if idx in obs_ids:
index = obs_ids.index(idx)
#print id,val,val.shape
self.datalist[index].simulated = val # in mol/mol
......@@ -291,35 +290,44 @@ class ObsPackObservations(Observation):
name, error, may_localize, may_reject = SitesWeights[key].split(';')
name = name.strip().lower()
error = float(error)
may_localize = bool(may_localize)
may_reject = bool(may_reject)
may_reject = ("TRUE" in may_reject.upper())
may_localize = ("TRUE" in may_localize.upper())
SiteCategories[name] = {'category': name, 'error': error, 'may_localize': may_localize, 'may_reject': may_reject}
#print name,SiteCategories[name]
SiteInfo = {}
SiteMove = {}
SiteHourly = {} # option added to include only certain hours of the day (for e.g. PAL) IvdL
for key, value in SitesWeights.iteritems():
if 'co2_' in key or 'sf6' in key: # to be fixed later, do not yet know how to parse valid keys from rc-files yet.... WP
sitename, sitecategory = key, value
sitename = sitename.strip()
sitecategory = sitecategory.split()[0].strip().lower()
SiteInfo[sitename] = SiteCategories[sitecategory]
#print sitename,SiteInfo[sitename]
if 'site.move' in key:
identifier, latmove, lonmove = value.split(';')
SiteMove[identifier.strip()] = (float(latmove), float(lonmove))
if 'site.hourly' in key:
identifier, hourfrom, hourto = value.split(';')
SiteHourly[identifier.strip()] = (int(hourfrom), int(hourto))
for obs in self.datalist: # loop over all available data points
obs.mdm = 1000.0 # default is very high model-data-mismatch, until explicitly set by script
obs.flag = 99 # default is do-not-use , until explicitly set by script
exclude_hourly = False # default is that hourly values are not included
identifier = obs.code
species, site, method, lab, datasetnr = identifier.split('_')
if SiteInfo.has_key(identifier):
if SiteInfo[identifier]['category'] == 'do-not-use':
if SiteInfo.has_key(identifier):
if SiteHourly.has_key(identifier):
hourf, hourt = SiteHourly[identifier]
if int(obs.xdate.hour) >= hourf and int(obs.xdate.hour) <= hourt:
logging.warning("Observation in hourly dataset INCLUDED, while sampling time %s was between %s:00-%s:00"%(obs.xdate.time(),hourf,hourt))
logging.warning("Observation in hourly dataset EXCLUDED, while sampling time %s was outside %s:00-%s:00"%(obs.xdate.time(),hourf,hourt))
exclude_hourly = True
if SiteInfo[identifier]['category'] == 'do-not-use' or exclude_hourly:
logging.warning("Observation found (%s, %d), but not used in assimilation !!!" % (identifier,
obs.mdm = SiteInfo[identifier]['error'] * self.global_R_scaling
obs.may_localize = SiteInfo[identifier]['may_localize']
......@@ -347,6 +355,7 @@ class ObsPackObservations(Observation):
self.SiteInfo = SiteInfo
self.SiteMove = SiteMove
self.SiteHourly = SiteHourly
logging.debug("Added Model Data Mismatch to all samples ")
......@@ -503,12 +512,10 @@ if __name__ == "__main__":
DaCycle = CycleControl(args={'rc':'../../dagriddedjet.rc'})
DaCycle = CycleControl(args={'rc':'../../ctdas-ei-gfed2-bcb-6x4-gridded.rc'})
DaSystem = CtDaSystem('../rc/carbontracker.rc')
DaSystem = CtDaSystem('../rc/carbontracker_geocarbon_gridded.rc')
DaCycle.DaSystem = DaSystem
......@@ -521,7 +528,6 @@ if __name__ == "__main__":
DaCycle['time.sample.end'] = DaCycle['time.end']
Supports Markdown
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