rabrahm / ceres

A set of pipelines and routines for echelle spectrographs
MIT License
39 stars 27 forks source link

update_ssephem wget no longer working #29

Open jvines opened 3 years ago

jvines commented 3 years ago

As stated in https://cddis.gsfc.nasa.gov/ anonymous ftp no longer works making the line gets to cddis.nasa.gov fail.

The new method is exemplified as follows:

Download the file 'cs2rx17001.001.Z' from archive directory '/doris/data/cs2/2017/' to your local file system.

--ftp-user anonymous = specifies the user name is "anonymous" --ftp-password = specifies that the password is your email address

wget --ftp-user anonymous --ftp-password ftps://gdc.cddis.eosdis.nasa.gov/doris/data/cs2/2017/cs2rx17001.001.Z

so lines 5 and 56 need updating

pmaxted commented 3 years ago

This is as far as I got with a solution for this ...

Create an Earthdata Login account.

https://cddis.nasa.gov/Data_and_Derived_Products/CDDIS_Archive_Access.html then create a .netrc file with the line ...

machine cddis.gsfc.nasa.gov login <USERNAME> password <PASSWORD>

.. then set the correct permission on this file ..

$ chmod 0600 .netrc

.. then change the addresses in the wget commands in ceres/utils/SSEphem/update_ssephem.py to

https://cddis.nasa.gov/archive/products/iers/finals2000A.data

and

https://cddis.nasa.gov/archive/products/iers/leapsec.dat

Unfortunately, these web addresses then do some complex redirection to the actual file that a browser can handle but I could not figure out how to make wget do this. Instead, I just downloaded the files and commented-out the wget commands.

jvines commented 2 years ago

@pmaxted I made a solution back then, sorry I didn't share it earlier.

This is my update_ssephem.py file:

import os
import numpy as np

def LeapSecUpdate():
    # os.system('wget --no-proxy --ftp-user jvines --ftp-password 11/Jose/08 ftps://cddis.gsfc.nasa.gov/pub/products/iers/leapsec.dat')
    os.system('wget --auth-no-challenge https://cddis.nasa.gov/archive/products/iers/leapsec.dat')
    # os.system('wget --no-proxy ftp://cddis.gsfc.nasa.gov/pub/products/iers/leapsec.dat')
    #os.system('wget --no-proxy http://maia.usno.navy.mil/ser7/leapsec.dat')
    if os.access('leapsec.tab', os.F_OK):
        os.system('mv leapsec.tab leapsec_old.tab')
    try:
        f = open('leapsec.dat','r')
        lines = f.readlines()
        fo = open('leapsec.tab','w')
        for line in lines:
            cos = line.split()
            if cos[1] == 'JAN':
                date = cos[0]+' January 1 '
            else:
                date = cos[0]+' July 1    '
            jd = float(cos[4])
            leap = float(cos[6])
            leap = int(np.around(leap))
            nline = '    '+str(int(np.around(jd-2400000.5)))+'       '+date+'TAI-UTC = '+str(leap)+'.0\n'
            fo.write(nline)
        f.close()
        fo.close()
        os.system('rm leapsec.dat')
    except:
        print 'No luck...'
        os.system('rm leapsec.dat')
        os.system('mv leapsec_old.tab leapsec.tab')

def SSEphemDownload():
    if os.access('DEc403',os.F_OK):
        os.system('mv DEc403 DEc403_old')
    if os.access('ascp2000.403', os.F_OK):
        os.system('mv ascp2000.403 ascp2000_old.403')
    os.system('wget ftp://ssd.jpl.nasa.gov/pub/eph/planets/ascii/de403/ascp2000.403')
    if os.access('header.403', os.F_OK):
        os.system('mv header.403 header_old.403')
    os.system('wget ftp://ssd.jpl.nasa.gov/pub/eph/planets/ascii/de403/header.403')
    if os.access('ascp2000.403', os.F_OK) == False or os.access('header.403', os.F_OK) == False:
        print 'No Luck...'
        os.system('mv ascp2000_old.403 ascp2000.403')
        os.system('mv header_old.403 header.403')
    else:
        os.system('cat header.403 ascp2000.403 > asc_cat.403')
        os.system('./asc2bin asc_cat.403 2451544 2484394')
    if os.access('DEc403',os.F_OK) == False:
        print 'No Luck...'
        if os.access('DEc403_old',os.F_OK):
            os.system('mv DEc403_old DEc403')

def IersUpdate():
    if os.access('finals2000A.data',os.F_OK):
        os.system('mv finals2000A.data finals2000A_old.data')
    # os.system('wget --no-proxy --ftp-user jvines --ftp-password 11/Jose/08 ftps://cddis.gsfc.nasa.gov/pub/products/iers/finals2000A.data')
    os.system('wget --auth-no-challenge https://cddis.nasa.gov/archive/products/iers/finals2000A.data')
    #os.system('wget --no-proxy http://maia.usno.navy.mil/ser7/finals2000A.data')
    if os.access('finals2000A.data',os.F_OK) == False:
        print 'one'
        print 'No Luck...'
        os.system('mv finals2000A_old.data finals2000A.data')
        pass
    else:
        if os.access('iers.tab',os.F_OK):
            os.system('mv iers.tab iers_old.tab')
        try:
            output = open('iers.tab','w')
            finaldata = open('finals2000A.data','r')
            for line in finaldata:
                mj = line[7:15]
                if len(line.split()) > 5:
                    c1 = line[18:27]
                    c2 = line[37:46]
                    c3 = line[58:68]
                    l  = ' '+mj+' '+c1+' '+c2+' '+c3+' '+'\n'
                    output.write(l)
            finaldata.close()
            output.close()
        except:
            print 'two'
            print 'No Luck...'
            if os.access('iers_old.tab',os.F_OK):
                os.system('mv iers_old.tab iers.tab')

I tested it today (05-02-2022) and it correctly downloaded and saved finals2000A.data