def get_profile_times(h5file):
    time_offset_seconds = get_geoloc_var(h5file, "Profile_time")
    UTC_start_time_seconds = get_geoloc_var(h5file, "UTC_start")[0]
    start_time_string = h5file["Swath Attributes"]["start_time"][0][0].decode("UTF-8")
    YYYYmmdd = start_time_string[0:8]
    base_time = datetime.strptime(YYYYmmdd, "%Y%m%d")
    UTC_start_offset = timedelta(seconds=UTC_start_time_seconds)
    profile_times = np.array(
        [
            base_time + UTC_start_offset + timedelta(seconds=x)
            for x in time_offset_seconds
        ]
    )

    da = xr.DataArray(
        data=profile_times,
        dims=["nray"],
        coords=dict(
            nray=range(len(profile_times)),
        ),
        attrs=dict(
            description="time",
        ),
    )
    return da
 def __init__(self, image: str, text: str, converter: PixelConverter):
     self.channels = Image.open(image).split()
     self.channels = [
         np.array(channel) / 256.0 for channel in self.channels
     ]
     self.text = text
     self.converter = converter
    def process(self, channel_filter):
        ch = self.converter.convert_to(self.channels)

        ones_matrix = np.ones(ch[0].shape, dtype=np.float64)

        ch_separated = [[
            ch[i] if j == i else ones_matrix * channel_filter[i][j]
            for j in range(self.converter.pixelspace)
        ] for i in range(self.converter.pixelspace)]

        ch_converted_separated = [
            np.array(self.converter.convert_from(c), dtype=np.float64)
            for c in ch_separated
        ]

        fig, axs = plt.subplots(2, 2)
        (ax1, ax2), (ax3, ax4) = axs
        ax = [ax1, ax2, ax3]

        for i, ch_conv in enumerate(ch_converted_separated):
            ax[i].axis('off')
            self.show_image(ax[i], ch_conv)
            extent = ax[i].get_window_extent().transformed(
                fig.dpi_scale_trans.inverted())
            plt.savefig("img" + str(i) + str(self.text) + ".png",
                        dpi=1000,
                        transparent=True,
                        bbox_inches=extent)
Example #4
0
# %% [markdown]
# or if you want to be more intuitive although not recommended by convention

# %%
from imports import *

# %%

# %%

# %% [markdown]
# link to [imps](./imports.py)

# %%
np.array([1, 2])

# %%
plt.plot([1, 2], [1, 2])

# %% [markdown]
# ## Scripts and Functions

# %% [markdown]
# link to
# [script](04-interaction.py)
# (python) version of this notebook
# (you need jupytext extension for it to work)

# %%
x = [1, 2, 3, 4, 5]
Example #5
0
pressure_grid = np.array(
    [
        24.0,
        25.0,
        26.0,
        27.0,
        28.0,
        29.0,
        30.0,
        32.0,
        33.0,
        34.0,
        35.0,
        37.0,
        38.0,
        40.0,
        41.0,
        43.0,
        44.0,
        45.0,
        48.0,
        50.0,
        52.0,
        54.0,
        55.0,
        58.0,
        60.0,
        63.0,
        65.0,
        68.0,
        70.0,
        73.0,
        75.0,
        80.0,
        83.0,
        85.0,
        90.0,
        93.0,
        98.0,
        100.0,
        105.0,
        110.0,
        113.0,
        115.0,
        120.0,
        125.0,
        130.0,
        135.0,
        140.0,
        145.0,
        155.0,
        160.0,
        165.0,
        170.0,
        180.0,
        185.0,
        190.0,
        200.0,
        210.0,
        215.0,
        225.0,
        230.0,
        240.0,
        250.0,
        260.0,
        270.0,
        280.0,
        290.0,
        300.0,
        310.0,
        320.0,
        330.0,
        345.0,
        360.0,
        370.0,
        380.0,
        395.0,
        400.0,
        425.0,
        440.0,
        450.0,
        470.0,
        480.0,
        500.0,
        515.0,
        530.0,
        550.0,
        570.0,
        585.0,
        600.0,
        625.0,
        645.0,
        665.0,
        685.0,
        700.0,
        725.0,
        750.0,
        770.0,
        800.0,
        825.0,
        850.0,
        870.0,
        900.0,
        925.0,
        950.0,
        988.0,
        1000.0,
        1010,
        1015,
        1020,
        np.nan,
        np.nan,
        np.nan,
        np.nan,
        np.nan,
        np.nan,
        np.nan,
        np.nan,
        np.nan,
        np.nan,
        np.nan,
        np.nan,
        np.nan,
        np.nan,
        np.nan,
        np.nan,
        np.nan,
    ]
)
all_slf_clean = all_slf.dropna()
# -

all_slf

all_slf_clean

# +
fig1 = plt.figure(figsize=(10, 6))  #constrained_layout=True)
spec1 = gridspec.GridSpec(ncols=3, nrows=1, figure=fig1)  #, hspace=0.4)
f1_ax1 = fig1.add_subplot(spec1[0, :-1])
f1_ax2 = fig1.add_subplot(spec1[0, -1], sharey=f1_ax1)
axes = [f1_ax1, f1_ax2]
plt.setp(f1_ax2.get_yticklabels(), visible=False)

isos = np.array(all_slf_clean.index).reshape(-1, 1)

fig1.gca().invert_yaxis()
f1_ax1.set_title('Supercooled Liquid Fraction Comparison')
f1_ax1.set_ylabel('Isotherm (C)')
f1_ax1.set_xlabel('SLF (%)')
f1_ax2.set_title('NorESM error')
f1_ax2.set_xlabel('SLF Error (%)')

colors = ['blue', 'orange']
models = ['NorESM_90N-70N', 'NorESM_Average']
caliops = ['CALIOP_90N-70N', 'CALIOP Average']
errors = ['Arctic Error', 'Global Error']

# Wrap everything up and iterate!
for color, model, caliop, error in zip(colors, models, caliops, errors):