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__datedate = "202401030236"

    # 00:30 to 16:36 of 2024-01-01
    start_date = "202401010030"
    end_date = "202401011636"

    # ONE YEAR 
    # start_date = "202401300000"
    # end_date = "202412312359"
    # end_date = "202402022359"

    # ONE MONTH - JANUARY 2024
    # start_date = "202401010000"
    # end_date = "202401312359"

    # outdir="/home/cmeikle/Projects/data/"
    # indir="/home/cmeikle/Projects/data/VIIRS/original_files/AERDB_L2_VIIRS_NOAA20"
    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"
    indir = ''
    filename_obs = 'carlotta'
    filename_num_obs = 'carlotta'

    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 = 100)
    # 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()
    end_time = time.time()
    elapsed_time = end_time - start_time
    print(f"Script executed in {elapsed_time:.2f} seconds.")


