innosat-mats / MATS-L1-processing

Python code for calibrating MATS images
MIT License
0 stars 1 forks source link

but in single event correction maps #233

Open lindamegner opened 2 months ago

lindamegner commented 2 months ago

πŸ› Description

IR1 and IR2 single event correction maps always seem to have at the corner pixel [186,43].

se_mask array([[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 1.]])

πŸ”’ To reproduce run code below

from mats_utils.rawdata.read_data import read_MATS_data import datetime as DT from mats_l1_processing.instrument import Instrument import numpy as np import matplotlib.pyplot as plt from database_generation.experimental_utils import plot_CCDimage from mats_utils.rawdata.calibration import calibrate_dataframe

import matplotlib.pyplot as plt

def plot_calib_step(dfentry, step1name,step2name,title,divide=False, clim1=None, clim2=None,clim3=None,fig=None, ax=None):

step1=dfentry[step1name]
step2=dfentry[step2name]

if fig is None:
    fig, ax = plt.subplots(3,1)
    fig.suptitle(title+' '+dfentry['channel'], fontsize=16)
if clim1 is None:
    clim1=[np.mean(step1)-np.std(step1), np.mean(step1)+np.std(step1)]
if clim2 is None:
    clim2=[np.mean(step2)-np.std(step2), np.mean(step2)+np.std(step2)]   
if divide:
    change=step2/step1
else:
    change=step2-step1

plot_CCDimage(step1, fig=fig, axis=ax[0], title=step1name, clim=clim1)
ax[0].text(10, 60, 'max: '+str(np.max(step1)), color='white')
ax[0].text(10, 80, 'min: '+str(np.min(step1)), color='white')
plot_CCDimage(step2, fig=fig, axis=ax[1], title=step2name, clim=clim2)
ax[1].text(10, 60, 'max: '+str(np.max(step2)), color='white')
ax[1].text(10, 80, 'min: '+str(np.min(step2)), color='white')

plot_CCDimage(change, fig=fig, axis=ax[2], title='change')
ax[2].text(10, 60, 'max: '+str(np.max(change)), color='white')
ax[2].text(10, 80, 'min: '+str(np.min(change)), color='white')

plt.tight_layout()
plt.show()

%%

dayornight='dayglow' if dayornight=='dayglow': start_time = DT.datetime(2023, 2, 20, 19, 20, 0) stop_time = DT.datetime(2023, 2, 20, 19, 21, 0) elif dayornight=='nightglow': start_time = DT.datetime(2023, 2, 20, 20, 48, 0) stop_time = DT.datetime(2023, 2, 20, 20, 49, 0) else: raise Exception('dayornight not defined')

df = read_MATS_data(start_time,stop_time,version='0.7',level='1a',dev=False)

n=2 uv1=df[df.channel=='UV1'][:n].reset_index() uv2=df[df.channel=='UV2'][:n].reset_index() ir1=df[df.channel=='IR1'][:n].reset_index() ir2=df[df.channel=='IR2'][:n].reset_index() ir3=df[df.channel=='IR3'][:n].reset_index() ir4=df[df.channel=='IR4'][:n].reset_index()

instrument = Instrument('/Users/lindamegner/MATS/MATS-retrieval/MATS-analysis/Linda/calibration_data_MATSinstrument.toml')

%%

uv1cal=calibrate_dataframe(uv1, instrument, debug_outputs=True) uv2cal=calibrate_dataframe(uv2, instrument, debug_outputs=True)

%%

ir1cal=calibrate_dataframe(ir1, instrument, debug_outputs=True)