Commit 42366dac authored by Florentie, Liesbeth's avatar Florentie, Liesbeth
Browse files

update to make sure flux output is also written if no observations in window...

update to make sure flux output is also written if no observations in window (no update statevector)
parent 021c4336
......@@ -37,6 +37,8 @@ def ensemble_smoother_pipeline(dacycle, platform, dasystem, samples, statevector
""" The main point of entry for the pipeline """
sys.path.append(os.getcwd())
samples = samples if isinstance(samples,list) else [samples]
logging.info(header + "Initializing current cycle" + footer)
start_job(dacycle, dasystem, platform, statevector, samples, obsoperator)
......@@ -391,6 +393,9 @@ def sample_step(dacycle, samples, statevector, obsoperator, lag, advance=False):
# Read observations (include option to read from different satellites) + perform observation selection
sample.add_observations(advance)
# If OSSE setup: overwrite obspack observation values by previously calculated samples
if hasattr(sample, 'osse') and sample.osse: sample.add_osse_observations(sample.osse_file)
# Add model-data mismatch to all samples, this *might* use output from the ensemble in the future??
sample.add_model_data_mismatch(dacycle.dasystem['obs.sites.rc'], advance)
......@@ -444,39 +449,40 @@ def invert(dacycle, statevector, optimizer):
logging.info(header + "starting invert" + footer)
if statevector.nobs == 0:
logging.info('List with observations to assimilate is empty, skipping invert step and continuing without statevector update...')
return
logging.warning('List with observations to assimilate is empty, skipping invert step and continuing without statevector update...')
else:
dims = (int(dacycle['time.nlag']),
int(dacycle['da.optimizer.nmembers']),
int(dacycle.dasystem['nparameters']),
statevector.nobs)
dims = (int(dacycle['time.nlag']),
int(dacycle['da.optimizer.nmembers']),
int(dacycle.dasystem['nparameters']),
statevector.nobs)
if not dacycle.dasystem.has_key('opt.algorithm'):
logging.info("There was no minimum least squares algorithm specified in the DA System rc file (key : opt.algorithm)")
logging.info("...using serial algorithm as default...")
optimizer.set_algorithm('Serial')
elif dacycle.dasystem['opt.algorithm'] == 'serial':
logging.info("Using the serial minimum least squares algorithm to solve ENKF equations")
optimizer.set_algorithm('Serial')
elif dacycle.dasystem['opt.algorithm'] == 'bulk':
logging.info("Using the bulk minimum least squares algorithm to solve ENKF equations")
optimizer.set_algorithm('Bulk')
if not dacycle.dasystem.has_key('opt.algorithm'):
logging.info("There was no minimum least squares algorithm specified in the DA System rc file (key : opt.algorithm)")
logging.info("...using serial algorithm as default...")
optimizer.set_algorithm('Serial')
elif dacycle.dasystem['opt.algorithm'] == 'serial':
logging.info("Using the serial minimum least squares algorithm to solve ENKF equations")
optimizer.set_algorithm('Serial')
elif dacycle.dasystem['opt.algorithm'] == 'bulk':
logging.info("Using the bulk minimum least squares algorithm to solve ENKF equations")
optimizer.set_algorithm('Bulk')
optimizer.setup(dims)
optimizer.state_to_matrix(statevector)
optimizer.setup(dims)
optimizer.state_to_matrix(statevector)
diagnostics_file = os.path.join(dacycle['dir.output'], 'optimizer.%s.nc' % dacycle['time.start'].strftime('%Y%m%d'))
diagnostics_file = os.path.join(dacycle['dir.output'], 'optimizer.%s.nc' % dacycle['time.start'].strftime('%Y%m%d'))
optimizer.write_diagnostics(diagnostics_file, 'prior')
optimizer.set_localization(dacycle['da.system.localization'])
optimizer.write_diagnostics(diagnostics_file, 'prior')
optimizer.set_localization(dacycle['da.system.localization'])
if optimizer.algorithm == 'Serial':
optimizer.serial_minimum_least_squares()
else:
optimizer.bulk_minimum_least_squares()
if optimizer.algorithm == 'Serial':
optimizer.serial_minimum_least_squares()
else:
optimizer.bulk_minimum_least_squares()
optimizer.matrix_to_state(statevector)
optimizer.matrix_to_state(statevector)
optimizer.write_diagnostics(diagnostics_file, 'optimized')
......
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