Skip to content
Snippets Groups Projects
Commit bb3b2820 authored by weihe's avatar weihe
Browse files

May 21 New observationoperator for WRF-STILT

parent 6dba86ae
No related branches found
No related tags found
No related merge requests found
......@@ -27,12 +27,12 @@ import subprocess #use to get info from running status
import numpy as np
from string import join
import glob
sys.path.append(os.getcwd())
sys.path.append("../../")
#sys.path.append(os.getcwd())
#sys.path.append("../../")
import da.tools.rc as rc
from da.tools.general import create_dirs, to_datetime
from da.baseclasses.observationoperator import ObservationOperator
#import da.tools.rc as rc
#from da.tools.general import create_dirs, to_datetime
#from da.baseclasses.observationoperator import ObservationOperator
# global constants, which will be used in the following classes
identifier = 'WRF-STILT'
......@@ -45,44 +45,57 @@ version = '1.0'
class STILTObservationOperator(ObservationOperator):
class STILTObservationOperator(object):
def __init__(self, filename): #only the filename used to specify the location of the stavector file for wrf-stilt runs
def __init__(self, dacycle=None): #only the filename used to specify the location of the stavector file for wrf-stilt runs
""" The instance of an STILTObservationOperator is application dependent """
self.ID = identifier # the identifier gives the model name
self.version = version # the model version used
self.restart_filelist = []
self.output_filelist = []
self.outputdir = None # Needed for opening the samples.nc files created
#self.load_rc(filename) # load the specified rc-file
#self.validate_rc() # validate the contents
#self.update_rc(filename)
self.simulated_file = None
self.forecast_nmembers = None
#self.simulated_file = None
#self.forecast_nmembers = None
# we need the folder of the input statevector and the path of the excecutable STILT procedure
self.rc=filename
#self.rc=filename
logging.info('Observation Operator initialized: %s (%s)' % (self.ID, self.version))
if dacycle != None:
self.dacycle = dacycle
else:
self.dacycle = {}
self.startdate=None
def get_initial_data(self):
""" This method places all initial data needed by an ObservationOperator in the proper folder for the model """
def setup(self, dacycle):
""" Execute all steps needed to prepare the ObsOperator for use inside CTDAS, only done at the very first cycle normally """
self.dacycle = dacycle
self.outputdir = dacycle['dir.output']
self.rc = dacycle['da.obsoperator.rc']
print "XXX%s" %(self.outputdir)
#print "XXX%s" %(self.rc)
def prepare_run(self):
""" Prepare the running of the actual forecast model, for example compile code """
import os
self.update_rc(self.rc)
ss=self.startdate.strftime("%Y%m%d")
print "XXX%s" %(ss)
self.outputdir= (self.outputdir)[0:(len(self.outputdir)-8)]+ss
print "XXX%s" %(self.outputdir)
# Define the name of the file that will contain the modeled output of each observation
self.simulated_file = os.path.join(self.outputdir, 'samples_simulated.%s.nc' % self. dacycle['time.sample.stamp'])
self.forecast_nmembers = int(self.dacycle['da.optimizer.nmembers'])
def update_rc(self, name):
def update_rc(self,name):
self.rc_filename = name
with open(name) as f:
......@@ -95,6 +108,7 @@ class STILTObservationOperator(ObservationOperator):
starttime = datetime.date(starttime.year,starttime.month,starttime.day) #YYYY-MM-DD
print "XXX%s" %(starttime)
data[26] = starttime
self.startdate=starttime
t=data.reshape((9, 3))
output = open(name, 'w')
......@@ -107,7 +121,7 @@ class STILTObservationOperator(ObservationOperator):
def run_forecast_model(self): #extral interface
self.prepare_run()
#self.validate_input()
self.update_rc(self.rc)
#self.update_rc(self.rc)
self.run()
#self.save_data()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment