#!/usr/bin/env python
# coding: utf-8

from datetime import datetime
import os
import sys
import time

import matplotlib.pyplot as plt
import netCDF4
import numpy as np

import omi

from orbit_sim import Orbit_sim




def main(name, instrument_file, output_path, start=0, end=5210):

    sim = Orbit_sim.from_file(instrument_file)

    for orbit in range(start, end):
        print('Orbit: %06d' % orbit)

        filename = os.path.join(
            output_path, '%s_o%06d.nc' % (name, orbit)
        )

        sim.phase_start = orbit + 0.30 # ~70°N
        sim.phase_end =   orbit + 0.40 # ~35°N

        sim.calculate_revolution()
        save_orbit(sim, filename, name)


def alpha(x):
    y = [-54.0]

    for i in x[1:]:
        f = (i - 225.0) / 225.

        if -1.0 <= f < -0.1 or 0.1 <= f < 1.0:
            y.append(y[-1] + 0.26)
        else:
            y.append(y[-1] + 0.52)

    return np.array(y)




if __name__ == '__main__':
    name = sys.argv[1]
    instrument_file = sys.argv[2]
    output_path = sys.argv[3]

    start = 0
    end = 800

    main(name, instrument_file, output_path, start, end)


