This repository holds the code necessary to reproduce the analysis presented in our paper on coastal sea level uncertainties: "Quantifying uncertainties in coastal sea level trends estimates using Jason altimetry observations (2002-2021)".
This has been tested under Python 3.12.10.
In the section src/hfnoise, the script get_hfnoise.py computes the high frequency noise variance associated with the geophysical corrections, for one station (R13 177 7). It creates a netCDF file containing this variance in output_hfnoise. It contains only the input files necessary for the treatment of one station, because the amount of input data was too important for all the stations.
In the section src/uncertainties, the script get_uncertainty.py takes as an input all the variance files in data_uncertainties/variances (which have been computed using get_hfnoise.py), all the trend files in data_uncertainties/trends, and computes the trend uncertainties for each virtual station, creating one netcdf file per station in output_uncertainties. In the process, it:
- Creates one yaml file per station, containing the characteristic values of each error source, and in particular, for the HF noise of geophysical corrections, the path to the variance file created with
get_hfnoise.py, and stored indata_uncertainties/variances. - Uses it as a configuration file in the script
rsl_track.py, which performs the analysis, by using several libraries to deal with IO, error covariance models and inversion (more details onrsl_track.pycan be found below). - Creates a netCDF file per station in
data_uncertainty/matvarcontaining the uncertainties and the error variance-covariance matrix Sigma.
Finally, a netCDF file per station is created in output_uncertainties, which corresponds to the initial trend file, with the uncertainty from data_uncertainties/matvar added on each point of the station.
For one station, and for each mission (Jason-2 and Jason-3), we:
- Extract the time series of each altimetric correction, for all the points of the station, and puts it in matrix form (nb_cycles,npts_track)
- Remove the outliers and fill the missing data
- Create all the possible SLA matrices by varying the altimetric corrections implied in the SLA computation (we obtain 648 different SLA)
- Filter each SLA matrix with a high pass filter of two months
- Compute the pair wise differences of each SLA matrix (there is 648 choose 2 differences)
- Compute the variances of each SLA difference matrix (there is 648 choose 2 array of variances, each array contains (npts_track) values)
- Compute the median of these variances (we obtain 1 array of medians, which contains one value per point of the track (len(median)=npts_track))
- Create a median matrix of size (npts_track, nb_cycles), containing the median values replicated on all the cycles of the mission. For Jason-2, we also replicate it on Jason-1 cycles, as we don't have input data for Jason-1.
Then, we concatenate the two median matrices (one per mission) into one of size (npts_track, nb_cycles_all_missions).
And we save the median matrices in a netCDF file in output_hfnoise
The code loops through positions on the track portion of the virtual station. At each position we:
- Construct the error variance-covariance matrix Sigma from the errors defined in the configuration file,
- Build the linear system design matrix,
- Invert the system to get model parameters and their uncertainty.
Results are written to a netCDF file in output_uncertainties.
The total error covariance matrix is estimated as the sum of all error terms, under an error independence hypothesis. The errors are defined in the configuration file by dictionnaries:
j1_j2_bias: {type: bias,
value: 2.0e-06,
timing: 2009.07}
the type key can take three values: bias, noise or drift.
Error amplitudes can be defined in the configuration file directly (in this case the same value is used at all positions) or read from a netCDF file (to allow for regional variations). When reading from a netCDF file filepath, variable name and conversion factor (defaults to 1.) should be provided in the configuration. Error amplitude values should be given in meters (orbit drift, gia drift) or square meters (biases, wtc_noise, sla_hp).
bias errors are defined by an amplitude and a timing (when they occur).
Timing must be provided as a float (in converted time units) in the conf file.
Amplitude can either be provided as a float using the value key of read from a netCDF gridded file when providing source and variable keywords.
Both
bias: {type: bias,
value: 1.,
timing: 2000.}
and
bias: {type: bias,
source: /path/to/file.nc,
variable: variable_name_in_nc_file,
timing: 2000.}
are valid.
noise errors are defined by an amplitude and a correlation scale (timescale).
Correlations must be provided as a float (in converted time units) in the conf file.
Amplitude can either be provided as a float using the value key of read from a netCDF gridded file when providing source and variable keywords.
Both
noise: {type: noise,
value: 1.,
timescale: 5.}
and
noise: {type: noise,
source: /path/to/file.nc,
variable: variable_name_in_nc_file,
timescale: 5.}
are valid.
drift errors are defined by an amplitude.
Amplitude can either be provided as a float using the value key of read from a netCDF gridded file when providing source and variable keywords.
Both
drift_error_name: {type: drift,
value: 1.}
and
drift_error_name: {type: drift,
source: /path/to/file.nc,
variable: variable_name_in_nc_file,
factor: 1.}
are valid.