Пример #1
0
def find_shifted_index(ds_subset, lat, lon, heights, nans):
    hvals = np.ma.ones(nans.shape)
    hvals.mask = nans
    hvals[~nans] = heights
    hvals[hvals < 1] = 0
    hvals = hvals.reshape(ds_subset.dims["x"], ds_subset.dims["y"]).T

    glon, glat = project_xy_to_latlon(ds_subset.x, ds_subset.y, ds_subset)

    apparent_cloudlocs = utils.RotatedECRPosition.from_geodetic(glat, glon, 0)
    actual_cloudlocs = utils.find_actual_cloud_position(
        ds_subset.erebos.spacecraft_location, apparent_cloudlocs, hvals)

    sun_pos = utils.get_solar_ecr_position(
        ds_subset.erebos.t.astype(int).item() / 1e9, lat, lon)
    shadowlocs = utils.find_apparent_cloud_position(sun_pos, actual_cloudlocs)

    site_pos = utils.RotatedECRPosition.from_geodetic(lat, lon, 0)

    sdist = dist(site_pos, shadowlocs)
    minargs = sdist.argsort(axis=-1)
    sorted_sdist = sdist.reshape(-1)[minargs]
    limit = (sorted_sdist < np.sqrt(3)).argmin()
    if limit == 0:
        return (10, 10)

    limhvals = hvals.ravel()[minargs[:limit]]
    shifted_loc = minargs[np.argmax(limhvals)]
    shifted_yx = np.unravel_index(shifted_loc, hvals.shape)  # y, x
    return shifted_yx
Пример #2
0
def test_find_position_roundtrip():
    app_cloud = utils.RotatedECRPosition(*APPARENT_POS)
    sat_pos = utils.RotatedECRPosition(*GOES17_POS)
    actual = utils.find_actual_cloud_position(sat_pos, app_cloud,
                                              CORRECTED_LATLONH[-1])
    app = utils.find_apparent_cloud_position(sat_pos, actual)
    np.testing.assert_allclose(app, app_cloud, rtol=1e-6)
Пример #3
0
def test_find_actual_cloud_position():
    app_cloud = utils.RotatedECRPosition(*APPARENT_POS)
    sat_pos = utils.RotatedECRPosition(*GOES17_POS)
    actual = utils.find_actual_cloud_position(sat_pos, app_cloud,
                                              CORRECTED_LATLONH[-1])
    exp = utils.RotatedECRPosition(*CORRECTED_POS)
    np.testing.assert_allclose(actual, exp)
Пример #4
0
def translate_calipso_locations(calipso_ds, goes_ds, fill_na=True, level=0):
    # nan means no cloud
    cloud_heights = calipso_ds.erebos.cloud_top_altitude[:, level].values
    if fill_na:
        cloud_heights = np.ma.fix_invalid(cloud_heights).filled(0)
    terrain_height = calipso_ds.erebos.surface_elevation[:, 0].values
    cloud_locations = utils.RotatedECRPosition.from_geodetic(
        calipso_ds.erebos.Latitude[:, 0].values,
        calipso_ds.erebos.Longitude[:, 0].values,
        0.0,
    )
    actual_cloud_pos = utils.find_actual_cloud_position(
        calipso_ds.erebos.spacecraft_location, cloud_locations, cloud_heights)
    apparent_cloud_pos = utils.find_apparent_cloud_position(
        goes_ds.erebos.spacecraft_location, actual_cloud_pos, terrain_height)
    alat, alon = apparent_cloud_pos.to_geodetic()
    goes_cloud_pos = goes_ds.erebos.crs.transform_points(
        ccrs.Geodetic(), alon, alat)
    return goes_cloud_pos[:, :2]
Пример #5
0
def test_find_actual_cloud_position_no_height():
    app_cloud = utils.RotatedECRPosition(*APPARENT_POS)
    sat_pos = utils.RotatedECRPosition(*GOES17_POS)
    actual = utils.find_actual_cloud_position(sat_pos, app_cloud, 0)
    np.testing.assert_allclose(actual, app_cloud, rtol=1e-6)