cena_coverageΒΆ

Display the time line that CENA data exists.

""" Display the time line that CENA data exists.
"""
import datetime
from irfpy.cena import cena_mass2 as cm2

def main():

    dtmax = datetime.timedelta(seconds=60)   # With data missing for ``dtmax`` seconds , it is considered as new session.

    orb0 = 1
    orb1 = 5000

    session = 0

    for orb in range(orb0, orb1):
        tlist = cm2.getobstime(orbit=orb)

        print('orbitnumber:{:04d}\tnspectra:{:d}'.format(orb, len(tlist)), end='')

        if len(tlist) != 0:
            print('\tstart:{:%FT%T}\tstop:{:%FT%T}'.format(tlist[0], tlist[-1]))

            current_start = None
            previous_t = None
            for current_t in tlist:
                if current_start is None:
                    current_start = previous_t = current_t
                    continue

                if current_t - previous_t >= dtmax:
                    print('session:{:d}\tstart:{:%FT%T}\tstop:{:%FT%T}\tduration:{:.1f}'.format(session, current_start, current_t, (current_t - current_start).total_seconds()))

                    session += 1
                    current_start = None
                    previous_t = None

                previous_t = current_t

            print('session:{:d}\tstart:{:%FT%T}\tstop:{:%FT%T}\tduration:{:.1f}'.format(session, current_start,current_t, (current_t - current_start).total_seconds()))
            session += 1

        else:
            print()

if __name__ == "__main__":
    main()