s3analysis

Specific functions for felyx S3 SLSTR match-up database handling

copyright:Copyright 2016 Ifremer / Cersat.
license:Released under GPL v3 license, see license.
class s3analysis.slstr.mdb.slstrmdb.SLSTRMDB(identifier=None, cfgfile=None, config=None)[source]

An abstraction class to read the SLSTR MDB records. It can be initialized in three different exclusive ways.

Parameters:
  • identifier (str, optional) – configuration identifier. If provided, a configuration file named <identifier>.cfg must exist in your $HOME/.s3analysis/mdb directory.
  • cfgfile (str, optional) – explicit path to configuration file (exclusive with identifier)
  • mdbroot (str, optional) – the path to the root directory where the match-up files are stored (with YYYY/DDD subfolders)
__module__ = 's3analysis.slstr.mdb.slstrmdb'
__str__(*args, **kwargs)[source]
add_wind_speed(matchups)[source]

Calculate and add the model wind speed

check_fields(matchups, fields)[source]

check that all required fields are in the matchup set

extract_value(fieldname, data, row, cell)[source]

extract the pixel pointed to by row and cell indices.

Override here for specific cases

get_algo_type_masks(matchups, use_wst_filter=True)[source]

return a selection mask for each algorithm type

Default settings as provided by G.Corlett

Parameters:dt_threshold (float) – maximum deviation to analysis
get_wct_selection(matchups, across_track_range=[0, 1500], min_wind_speed=6.0, max_sat_zen=55.0, dt_thresh=5.0)[source]

return a selection of the match-ups in the proper range of validity.

Default settings as provided by G.Corlett

get_wst_selection(matchups, insitu, dt_thresh=5.0, min_quality_level=2)[source]

return a selection of the match-ups in the proper range of validity.

Default settings as provided by G.Corlett

load_config(identifier)[source]
quality_level(matchups)[source]

Return an experimental quality level

read_aux_data(source, day, fields, end_day=None, filters=None)[source]

Read the auxiliary files generated by Gary Corlett

Parameters:
  • source (str) – the site collections (cmems_drifter, cmems_argo, etc…)
  • day (datetime) – the date (or start date if end_date is also set) for which to retrieve the matchup in situ values
  • matchup_root (str) – the path to the root repository where the matchup files are stored.
  • fields (list) – a list of fields to read (remove the level suffix: for instance, use cmems_water_temperature instead of cmems_water_temperature_0 and the function will detect and reconstruct the two dimensional fields for you).
Returns:

a dict where keys are field names, and values the retrieved data

read_cloud_mask(source, day, matchup_root, end_day=None, box=False, max_distance=None, maskvar='S3A_SL_2_WCT__cloud_in', maskbits=None, multiple_mask=False)[source]

Return a cloud mask from ‘S3A_SL_2_WCT__cloud_in’ flag

Parameters:
  • maskvar (str) – the bitmask field name (ex: ‘S3A_SL_2_WCT__cloud_in’)
  • maskbits (list, optional) – list of bits to test for cloud mask extraction, if you don’t want to use default values (preset for ‘S3A_SL_2_WCT__cloud_in’ variable), as a list of flag meanings.
  • multiple_mask (boolean, optional) – if False (default), return a single mask array. If True, return a mask array for each mask bit within a dictionary.
Returns:

an array of boolean (True is set when cloudy) if multiple_mask keyword is not set, or a dictionary of boolean arrays (one for each mask bit testes).

Return type:

numpy.ndarray or dict of numpy.ndarray

Created on Jun 26, 2017

@author: jfpiolle

s3analysis.slstr.cloud.cloud_mask(bitmask, flagmeanings=['visible', '1.37_threshold', '1.6_small_histogram', '1.6_large_histogram', '2.25_small_histogram', '2.25_large_histogram', '11_spatial_coherence', 'gross_cloud', 'thin_cirrus', 'medium_high', 'fog_low_stratus', '11_12_view_difference', '3.7_11_view_difference', 'thermal_histogram', 'spare', 'spare'], flags=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768], bits=['visible', '1.37_threshold', '1.6_large_histogram', '2.25_large_histogram', 'gross_cloud', 'thin_cirrus', 'medium_high', '11_12_view_difference', '3.7_11_view_difference', 'fog_low_stratus', '11_spatial_coherence'])[source]

Build the cloud mask from the bitmask variable and the positional bits.

Parameters:
  • bitmask (numpy.ndarray) – the bitmask array (ex: content of ‘cloud_in’ variable)
  • flagmeanings (list) – the list of flag meanings (explanation associated with each flag value, as provided in flag_meanings CF attribute
  • flags (list) – the list of flag values, as provided in flag_masks CF attribute
  • bits (list, optional) –

    list of bits to test for cloud mask extraction, if you don’t want to use default values (preset for ‘S3A_SL_2_WCT__cloud_in’ variable). The default flag selection is:

    • 1.37_threshold
    • gross_cloud
    • thin_cirrus
    • medium_high
    • 11_12_view_difference
    • 3.7_11_view_difference
    • fog_low_stratus
    • 11_spatial_coherence
Returns:

array of boolean (True when cloudy)

Return type:

numpy.ndarray

s3analysis.slstr.cloud.cloud_summary(bitmask, flagmeanings=['visible', '1.37_threshold', '1.6_small_histogram', '1.6_large_histogram', '2.25_small_histogram', '2.25_large_histogram', '11_spatial_coherence', 'gross_cloud', 'thin_cirrus', 'medium_high', 'fog_low_stratus', '11_12_view_difference', '3.7_11_view_difference', 'thermal_histogram', 'spare', 'spare'], flags=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768], bits=['visible', '1.37_threshold', '1.6_large_histogram', '2.25_large_histogram', 'gross_cloud', 'thin_cirrus', 'medium_high', '11_12_view_difference', '3.7_11_view_difference', 'fog_low_stratus', '11_spatial_coherence'])[source]

Return the cloud summary, flag by flag

Parameters:
  • bitmask (numpy.ndarray) – the bitmask array (ex: content of ‘cloud_in’ variable)
  • flagmeanings (list) – the list of flag meanings (explanation associated with each flag value, as provided in flag_meanings CF attribute
  • flags (list) – the list of flag values, as provided in flag_masks CF attribute
Returns:

a dictionary of boolean arrays (True is set when cloudy), one for each mask bit tested.

Return type:

dict of numpy.ndarray

Created on Jun 26, 2017

@author: jfpiolle

s3analysis.slstr.quality_level.granule_quality_level(wst, wct, dt_threshold=5.0)[source]

Return the quality level field given a pair of WST and WCT granules provided as cerbere Swath objects.

Parameters:
  • ( (wct) – py:class:cerbere.datamodel.swath.Swath)
  • ( – py:class:cerbere.datamodel.swath.Swath)
s3analysis.slstr.quality_level.quality_level(l2p_flags, cloud, sst_algo, uncertainty, dt_analysis, sst, dt_threshold=5.0)[source]

process the quality level

Default settings as provided by G.Corlett

Parameters:cloud – a cloud mask or a tuple (nadir cloud mask, oblique cloud mask)