#!/bin/env python 
import argparse
import os,sys
import subprocess
from datetime import datetime, timedelta
from aiub_gnss_data import AIUBData, wget_aiub_gnss
from nasa_gnss_data import NASAData,wget_nasa_gnss

'''
#####################################################################
#
# rt_wget_gnss_ultra.py
#
# Purpose:
# This Python driver script retrieves COD0OPSULT GNSS product data
# from NASA servers for use in downstream processing.
# https://cddis.nasa.gov/archive/gnss/products/ 
#
# History:
#       Created by: Ming Chen 2026/04/24
#                   ming.chen@noaa.gov
#
# Usage: python  rt_wget_gnss_ultra.py  Args
#
# Args: datetime_str in "%Y%m%dT%H" 
#
#####################################################################

'''


def parse_args():

    # Set up main parser
    parser = argparse.ArgumentParser(description="batch driver of the leopod generation")
    parser.add_argument("-v","--verbose", action='store_true',  help="print info for debug")
    parser.add_argument("datetime", type=str, help = "%Y%m%dT%H")
 
    return parser.parse_args()

def main(): 
    args = parse_args()
    ddt = datetime.strptime(args.datetime, "%Y%m%dT%H")
    product = "COD0OPSULT"
    pdate = ddt.strftime("%Y%m%d")
    hh = ddt.strftime("%H")
    hour = int(hh)
    if hh not in ['00','06', '12','18']: sys.exit(1)
    if not NASAData.valid_product(product): sys.exit(1)
    wget_nasa_gnss(product, pdate, hour=hour)
  

if __name__ == "__main__":
    main()

