Пример #1
0
    def __init__(self, lsm_dir, t_dim=None, t_centered=True):
        from .constants import LSM_NPY_FILENAME, DEPTH_NPY_FILENAME

        cache = util.cache.HDD_NPY_Cache(lsm_dir)
        depth = cache.get_value(DEPTH_NPY_FILENAME, self._calculate_depth)
        lsm = cache.get_value(LSM_NPY_FILENAME, self._calculate_lsm)

        super().__init__(lsm, depth, t_dim=t_dim, t_centered=t_centered)
Пример #2
0
    def __init__(self, lsm_dir, t_dim=None, t_centered=True):
        from .constants import LSM_NPY_FILENAME, DEPTH_NPY_FILENAME

        cache = util.cache.HDD_NPY_Cache(lsm_dir)
        depth = cache.get_value(DEPTH_NPY_FILENAME, self._calculate_depth)
        lsm = cache.get_value(LSM_NPY_FILENAME, self._calculate_lsm)

        super().__init__(lsm, depth, t_dim=t_dim, t_centered=t_centered)
Пример #3
0
def load_ladolfi_2004():
    from measurements.dop.pw.constants import DATA_FILENAME, LADOLFI_2004_DIR, LADOLFI_2004_MEASUREMENT_FILE, LADOLFI_2004_START_DATE, LADOLFI_2004_END_DATE, LADOLFI_2004_VALID_DATA_FLAG

    cache = util.cache.HDD_NPY_Cache(LADOLFI_2004_DIR)
    calculation_function = lambda : prepare_ladolfi_data(LADOLFI_2004_MEASUREMENT_FILE, LADOLFI_2004_START_DATE, LADOLFI_2004_END_DATE, LADOLFI_2004_VALID_DATA_FLAG)

    return cache.get_value(DATA_FILENAME, calculation_function)
Пример #4
0
def load_yoshimura_2007():
    from measurements.dop.pw.constants import DATA_FILENAME, YOSHIMURA_2007_DIR, YOSHIMURA_2007_MEASUREMENT_FILE

    cache = util.cache.HDD_NPY_Cache(YOSHIMURA_2007_DIR)
    calculation_function = lambda : prepare_yoshimura_data(YOSHIMURA_2007_MEASUREMENT_FILE)

    return cache.get_value(DATA_FILENAME, calculation_function)
Пример #5
0
def points_near_water_mask(lsm, max_land_boxes=0):
    cache = util.cache.HDD_NPY_Cache(measurements.dop.pw.constants.DATA_DIR)
    filename = measurements.dop.pw.constants.MEASUREMENTS_POINTS_ARE_NEAR_WATER_FILENAME.format(
        lsm=lsm, max_land_boxes=max_land_boxes)
    return cache.get_value(
        filename,
        lambda: lsm.points_near_water_mask(points(),
                                           max_land_boxes=max_land_boxes))
Пример #6
0
def load_yoshimura_2007():
    from measurements.dop.pw.constants import DATA_FILENAME, YOSHIMURA_2007_DIR, YOSHIMURA_2007_MEASUREMENT_FILE

    cache = util.cache.HDD_NPY_Cache(YOSHIMURA_2007_DIR)
    calculation_function = lambda: prepare_yoshimura_data(
        YOSHIMURA_2007_MEASUREMENT_FILE)

    return cache.get_value(DATA_FILENAME, calculation_function)
Пример #7
0
def load_ladolfi_2004():
    from measurements.dop.pw.constants import DATA_FILENAME, LADOLFI_2004_DIR, LADOLFI_2004_MEASUREMENT_FILE, LADOLFI_2004_START_DATE, LADOLFI_2004_END_DATE, LADOLFI_2004_VALID_DATA_FLAG

    cache = util.cache.HDD_NPY_Cache(LADOLFI_2004_DIR)
    calculation_function = lambda: prepare_ladolfi_data(
        LADOLFI_2004_MEASUREMENT_FILE, LADOLFI_2004_START_DATE,
        LADOLFI_2004_END_DATE, LADOLFI_2004_VALID_DATA_FLAG)

    return cache.get_value(DATA_FILENAME, calculation_function)
Пример #8
0
def measurements_same_points(min_values, sample_lsm=SAMPLE_LSM):
    from measurements.po4.wod.correlation.constants import VALUE_DIR, MEASUREMENTS_SAME_POINTS_FILENAME

    def calculate_function():
        m = measurements.po4.wod.data.results.Measurements.load()
        m.categorize_indices_to_lsm(sample_lsm, discard_year=False)
        m.means(return_type='self')
        return m.filter_same_points_except_year(min_values=min_values)

    cache = util.cache.HDD_ObjectWithSaveCache(VALUE_DIR, measurements.util.data.MeasurementsSamePoints.load)
    return cache.get_value(MEASUREMENTS_SAME_POINTS_FILENAME.format(min_values=min_values, sample_lsm=sample_lsm), calculate_function)
Пример #9
0
def sample_values(value_type, min_values, max_year_diff=float('inf'), sample_lsm=SAMPLE_LSM):
    POSSIBLE_VALUE_TYPES = ('correlation', 'covariance')
    if value_type not in POSSIBLE_VALUE_TYPES:
        raise ValueError('Value type has to be in {} but it is {}.'.format(POSSIBLE_VALUE_TYPES, value_type))

    from measurements.po4.wod.correlation.constants import VALUE_DIR, DIFFERENT_BOXES_SAMPLE_VALUE_DICT_FILENAME

    def calculate_function():
        ms = measurements_same_points(min_values=min_values, sample_lsm=sample_lsm)
        covariance = ms.correlation_or_covariance(value_type, min_values=min_values, stationary=False, max_year_diff=max_year_diff)
        return covariance

    cache = util.cache.HDD_ObjectWithSaveCache(VALUE_DIR, measurements.util.data.MeasurementsCovariance.load)
    return cache.get_value(DIFFERENT_BOXES_SAMPLE_VALUE_DICT_FILENAME.format(type=value_type, max_year_diff=max_year_diff, min_values=min_values, sample_lsm=sample_lsm), calculate_function)
Пример #10
0
def sample_values_transformed(value_type, min_values, max_year_diff=float('inf'), sample_lsm=SAMPLE_LSM):
    POSSIBLE_VALUE_TYPES = ('correlation', 'covariance')
    if value_type not in POSSIBLE_VALUE_TYPES:
        raise ValueError('Value type has to be in {} but it is {}.'.format(POSSIBLE_VALUE_TYPES, value_type))

    from measurements.po4.wod.correlation.constants import VALUE_DIR, DIFFERENT_BOXES_SAMPLE_VALUE_DICT_TRANSFORMED_FILENAME

    def calculate_function():
        value_dict = sample_values(value_type, min_values=min_values, max_year_diff=max_year_diff, sample_lsm=sample_lsm)
        # value_dict = transform_sample_value_dict(value_dict)
        value_dict.coordinates_to_map_indices(sample_lsm, float_indices=False)
        return value_dict

    cache = util.cache.HDD_ObjectWithSaveCache(VALUE_DIR, measurements.util.data.MeasurementsCovariance.load)
    return cache.get_value(DIFFERENT_BOXES_SAMPLE_VALUE_DICT_TRANSFORMED_FILENAME.format(type=value_type, max_year_diff=max_year_diff, min_values=min_values, sample_lsm=sample_lsm), calculate_function)
Пример #11
0
def points_near_water_mask(lsm, max_land_boxes=0):
    cache = util.cache.HDD_NPY_Cache(measurements.dop.pw.constants.DATA_DIR)
    filename = measurements.dop.pw.constants.MEASUREMENTS_POINTS_ARE_NEAR_WATER_FILENAME.format(lsm=lsm, max_land_boxes=max_land_boxes)
    return cache.get_value(filename, lambda: lsm.points_near_water_mask(points(), max_land_boxes=max_land_boxes))
Пример #12
0
def results():
    cache = util.cache.HDD_NPY_Cache(measurements.dop.pw.constants.DATA_DIR)
    return cache.get_value(measurements.dop.pw.constants.MEASUREMENTS_RESULTS_FILENAME, lambda :points_and_results()[1])
Пример #13
0
def results():
    cache = util.cache.HDD_NPY_Cache(measurements.po4.wod.data.constants.DATA_DIR)
    return cache.get_value(measurements.po4.wod.data.constants.MEASUREMENTS_RESULTS_FILENAME, lambda :measurements_calculate()[1])
Пример #14
0
def measurement_dict_unsorted():
    cache = util.cache.HDD_ObjectWithSaveCache(measurements.po4.wod.data.constants.DATA_DIR, measurements.util.data.Measurements.load)
    return cache.get_value(measurements.po4.wod.data.constants.MEASUREMENTS_DICT_UNSORTED_FILENAME, measurement_dict_unsorted_calculate)
Пример #15
0
def cruises_list():
    cache = util.cache.HDD_ObjectCache(measurements.po4.wod.data.constants.DATA_DIR)
    return cache.get_value(measurements.po4.wod.data.constants.CRUISES_LIST_FILENAME, cruises_list_calculate)
Пример #16
0
def results():
    cache = util.cache.HDD_NPY_Cache(measurements.dop.pw.constants.DATA_DIR)
    return cache.get_value(
        measurements.dop.pw.constants.MEASUREMENTS_RESULTS_FILENAME,
        lambda: points_and_results()[1])