コード例 #1
0
def _create_seadas_chlor_a_file(full_path, mission, sensor):
    h = SD(full_path, SDC.WRITE | SDC.CREATE)
    setattr(h, "Sensor Name", sensor)
    h.Mission = mission
    setattr(h, "Start Time", "2021322175853191")
    setattr(h, "End Time", "2021322180551214")

    lon_info = {
        "type": SDC.FLOAT32,
        "data": np.zeros((5, 5), dtype=np.float32),
        "dim_labels":
        ["Number of Scan Lines", "Number of Pixel Control Points"],
        "attrs": {
            "long_name": "Longitude\x00",
            "standard_name": "longitude\x00",
            "units": "degrees_east\x00",
            "valid_range": (-180.0, 180.0),
        }
    }
    lat_info = {
        "type": SDC.FLOAT32,
        "data": np.zeros((5, 5), np.float32),
        "dim_labels":
        ["Number of Scan Lines", "Number of Pixel Control Points"],
        "attrs": {
            "long_name": "Latitude\x00",
            "standard_name": "latitude\x00",
            "units": "degrees_north\x00",
            "valid_range": (-90.0, 90.0),
        }
    }
    _add_variable_to_file(h, "longitude", lon_info)
    _add_variable_to_file(h, "latitude", lat_info)

    chlor_a_info = {
        "type": SDC.FLOAT32,
        "data": np.ones((5, 5), np.float32),
        "dim_labels":
        ["Number of Scan Lines", "Number of Pixel Control Points"],
        "attrs": {
            "long_name": "Chlorophyll Concentration, OCI Algorithm\x00",
            "units": "mg m^-3\x00",
            "standard_name":
            "mass_concentration_of_chlorophyll_in_sea_water\x00",
            "valid_range": (0.001, 100.0),
        }
    }
    _add_variable_to_file(h, "chlor_a", chlor_a_info)

    l2_flags = np.zeros((5, 5), dtype=np.int32)
    l2_flags[2, 2] = -1
    l2_flags_info = {
        "type": SDC.INT32,
        "data": l2_flags,
        "dim_labels":
        ["Number of Scan Lines", "Number of Pixel Control Points"],
        "attrs": {},
    }
    _add_variable_to_file(h, "l2_flags", l2_flags_info)
    return [full_path]