コード例 #1
0
data = read("data/SABOR/sabor_HyperPro_2014.txt", data_start=35)
header = read("data/SABOR/sabor_HyperPro_2014.txt", data_start=32, data_end=33)
header["col1"][0] = "date"
header = header[0].as_void()

for key, new_key in zip(data.keys(), header):
    data.rename_column(key, new_key)

data.remove_columns(get_keys_with_label(data, "sd"))
data.remove_columns(get_keys_with_label(data, "Lu"))

data.rename_column("lat", "Latitude")
data.rename_column("lon", "Longitude")

rename_columns(data, "Ed", "Ed_")
rename_columns(data, "Rrs", "R_rs_")

convert_to_unit(data, "Ed", u.microwatt / (u.centimeter**2 * u.nanometer),
                u.watt / (u.meter**2 * u.nanometer))
convert_to_unit(data, "R_rs", 1 / u.steradian)

data = add_Lw_from_Ed_Rrs(data)

map_data(data,
         data_label="SABOR-H",
         projection="gnom",
         lat_0=37,
         lon_0=-70,
         llcrnrlon=-77,
         urcrnrlon=-64,
コード例 #2
0
files = list(folder.glob("Tara_HyperPro*.txt"))

data = table.vstack([read(file, data_start=35) for file in files])

header = read(files[0], data_start=32, data_end=33)
header["col1"][0] = "year"
header = header[0].as_void()

for key, new_key in zip(data.keys(), header):
    data.rename_column(key, new_key)

data.remove_columns(get_keys_with_label(data, "LU"))

data.rename_column("lat", "Latitude")
data.rename_column("lon", "Longitude")

rename_columns(data, "ES", "Ed_", exclude="None")
rename_columns(data, "Rrs", "R_rs_", exclude="None")

convert_to_unit(data, "Ed", u.microwatt / (u.centimeter**2 * u.nanometer),
                u.watt / (u.meter**2 * u.nanometer))
convert_to_unit(data, "R_rs", 1 / u.steradian)

data = add_Lw_from_Ed_Rrs(data)

map_data(data, data_label="TaraO", lon_0=0, resolution="i")

plot_spectra(data, data_label="TaraO", alpha=0.1)

write_data(data, label="TaraO")
コード例 #3
0
from astropy import table
from astropy import units as u
from sba.plotting import plot_spectra, map_data
from sba.io import read, write_data
from sba.data_processing import split_spectrum, get_keys_with_label, remove_negative_R_rs, convert_to_unit, rename_columns

Ed = read("data/SOP4/SO-P4_irrad.tab", data_start=142, header_start=141)
Lu = read("data/SOP4/SO-P4_rad_up_40deg.tab", data_start=142, header_start=141)
Ls = read("data/SOP4/SO-P4_sky_rad_40deg.tab",
          data_start=142,
          header_start=141)

data = table.join(Ed, Lu, keys=["Date/Time"])
data = table.join(data, Ls, keys=["Date/Time"])

rename_columns(data, "Ed", "Ed", strip=True)
rename_columns(data, "Lu", "Lu", strip=True)
rename_columns(data, "Ls", "Ls", strip=True)

convert_to_unit(data, "Ed", u.watt / (u.meter**2 * u.nanometer))
convert_to_unit(data, "Lu",
                u.microwatt / (u.centimeter**2 * u.nanometer * u.steradian),
                u.watt / (u.meter**2 * u.nanometer * u.steradian))
convert_to_unit(data, "Ls", u.watt / (u.meter**2 * u.nanometer * u.steradian))

Ed_keys, Lu_keys, Ls_keys = get_keys_with_label(data, "Ed", "Lu", "Ls")
for Ed_k, Lu_k, Ls_k in zip(Ed_keys, Lu_keys, Ls_keys):
    Lw_k = Lu_k.replace("Lu", "Lw")
    Lw = data[Lu_k] - 0.028 * data[Ls_k]
    Lw.name = Lw_k
    data.add_column(Lw)
コード例 #4
0
colnames_rrs = [f"R_rs_{wvl:.1f}" for wvl in wavelengths]
colnames_rrs2 = [f"R_rs_err_{wvl:.1f}" for wvl in wavelengths]
colnames = colnames + colnames_rrs + colnames_rrs2

for j, newname in enumerate(colnames, 1):
    Rrs.rename_column(f"col{j}", newname)
Rrs.remove_columns(colnames_rrs2)
Rrs.remove_columns([
    'Ratio (drho/rho, 750nm)', 'Ratio (dLsky/Lsky, 750nm)',
    'Ratio (dLw/Lw, 750nm)', 'Ratio (dEd/Ed, 750nm)',
    'Ratio (d(Lsk/Ed)/(Lsk/Ed), 750nm)'
])

data = table.join(Ed, Rrs, keys=["ID"])

rename_columns(data, "Ed [mW/m**2/nm] (", "Ed_", strip=True)

convert_to_unit(data, "Ed", u.milliwatt / (u.meter**2 * u.nanometer),
                u.watt / (u.meter**2 * u.nanometer))
convert_to_unit(data, "R_rs", 1 / u.steradian)

R_rs_keys = get_keys_with_label(data, "R_rs")
for R_rs_k in zip(R_rs_keys):
    # Convert R_w to R_rs
    data[R_rs_k] = data[R_rs_k] / np.pi

data = add_Lw_from_Ed_Rrs(data)

remove_negative_R_rs(data)

map_data(data,
コード例 #5
0
import numpy as np
from astropy import table
from astropy import units as u
from sba.plotting import plot_spectra, map_data
from sba.io import read, write_data
from sba.data_processing import convert_to_unit, rename_columns, add_Lw_from_Ed_Rrs

Ed = read("data/HE302/HE302_irrad.tab", data_start=186, header_start=185)
Rrs = read("data/HE302/HE302_rrs.tab", data_start=186, header_start=185)

data = table.join(Ed, Rrs, keys=["Event"])

rename_columns(data, "Ed", "Ed", strip=True)
rename_columns(data, "Rrs", "R_rs", strip=True)

convert_to_unit(data, "Ed", u.watt / (u.meter**2 * u.nanometer))
convert_to_unit(data, "R_rs", 1 / u.steradian)

data = add_Lw_from_Ed_Rrs(data)

remove_indices = [i for i, row in enumerate(data) if row["R_rs_800"] >= 0.003]
data.remove_rows(remove_indices)
print(f"Removed {len(remove_indices)} rows with values of R_rs(800 nm) >= 0.003")

for key in ["Date/Time", "Latitude", "Longitude", "Altitude [m]"]:
    data.rename_column(f"{key}_1", key)
    data.remove_column(f"{key}_2")

map_data(data, data_label="HE302", projection='gnom', lat_0=55, lon_0=0, llcrnrlon=-10, urcrnrlon=11, llcrnrlat=50.5, urcrnrlat=59.5, resolution="h", parallels=np.arange(40, 70, 2), meridians=np.arange(-20, 20, 2))

plot_spectra(data, data_label="HE302", alpha=0.15)
コード例 #6
0
    mean_data = [*data_table[0]["year", "jd"], row["time_GMT"], *means]
    data_table.add_row(mean_data)
    data_table.remove_rows(np.arange(len(data_table) - 1))

    # Finally, load lat/lon
    *_, lon, lat = find_auxiliary_information_seabass(data_files[0])
    data_table.add_column(table.Column(name="Longitude", data=[lon]))
    data_table.add_column(table.Column(name="Latitude", data=[lat]))

    data.append(data_table)

    print(j, row["Station"])

data = table.vstack(data)

rename_columns("Es", "Ed_")
rename_columns("Lsky", "Ls_")
rename_columns("Lt", "Lt_")

convert_to_unit(data, "Ed", u.microwatt / (u.centimeter**2 * u.nanometer),
                u.watt / (u.meter**2 * u.nanometer))
convert_to_unit(data, "Ls",
                u.microwatt / (u.centimeter**2 * u.nanometer * u.steradian),
                u.watt / (u.meter**2 * u.nanometer * u.steradian))
convert_to_unit(data, "Lt",
                u.microwatt / (u.centimeter**2 * u.nanometer * u.steradian),
                u.watt / (u.meter**2 * u.nanometer * u.steradian))

Ed_keys, Ls_keys, Lt_keys = get_keys_with_label(data, "Ed", "Ls", "Lt")
for Ed_k, Ls_k, Lt_k in zip(Ed_keys, Ls_keys, Lt_keys):
    wavelength = int(Ed_k[3:])
コード例 #7
0
wavelengths = np.arange(350, 1301, 1)

Ld = read("data/SeaSWIR/SeaSWIR_ASD_Ldspec.tab", data_start=974, header_start=973)
Ldkeys = get_keys_with_label(Ld, "Ld")
for Ldkey, wvl in zip(Ldkeys, wavelengths):
    # multiply by pi to convert L to E (Mobley99)
    # divide by 1e5 for normalisation to W/m^2/nm (empirical)
    Ed = Ld[Ldkey] * np.pi / 1e5
    Ed.name = f"Ed_{wvl}"
    Ld.add_column(Ed)
    Ld.remove_column(Ldkey)
Ed = Ld
# Units of Ld are not provided

Rrs = read("data/SeaSWIR/SeaSWIR_ASD_Rw.tab", data_start=974, header_start=973)
rename_columns(Rrs, "Refl (", "R_rs_", strip=True)
R_rs_keys = get_keys_with_label(Rrs, "R_rs")
for R_rs_k in R_rs_keys:
    # Convert R_w to R_rs
    Rrs[R_rs_k] = Rrs[R_rs_k] / np.pi

data = table.join(Ed, Rrs, keys=["Station"])

convert_to_unit(data, "Ed", u.watt / (u.meter**2 * u.nanometer))
convert_to_unit(data, "R_rs", 1 / u.steradian)

data = add_Lw_from_Ed_Rrs(data)

for key in data.keys():
    if key[-2:] == "_1":
        data.rename_column(key, key[:-2])