from mapies.viirs import VIIRS
import time
# from dask.distributed import Client


if __name__ == "__main__":
    # Change these variables
    # 00:30 to 02:36 from 2024-01-01 to 2024-01-03
    start_date = "202401010030"
    end_date = "202401030236"

    filename_obs = '1month_obs.png'
    filename_num_obs = '1month_num_obs.png'

    outdir = "/home/cgile/Documents/mapies/figures"
    indir = "/home/cgile/bscearth000/esarchive/obs/nasa/viirs_noaa20_aerdb_l2/original_files/VIIRS"
    # indir = "/home/cgile/Documents/mapies/VIIRS"
    


    start_time = time.time()

    c = VIIRS(start_date, end_date, dest=outdir, indir=indir, apply_qa=False, grid_repr="rotated")
    c.read_nc()
    c.process_data(monthly_avg=False, batch_size = 50, geospatial_crop=[[-30, 50], [0, 50]])
    # c.yearly_average()
    # c.plot_2D_observations(months=[0], filename=filename_obs, outdir=outdir)
    # c.plot_2D_num_obs(months=[0], filename=filename_num_obs, outdir=outdir)
    c.process_lazy_data()

    c.plot_2D_observations(months=[0], filename=filename_obs, outdir=outdir, display_fig=True)

    end_time = time.time()
    elapsed_time = end_time - start_time
    print(f"Script executed in {elapsed_time:.2f} seconds.")


