lofar-astron / RMextract

extract TEC, vTEC, Earthmagnetic field and Rotation Measures from GPS and WMM data for radio interferometry observations
GNU General Public License v3.0
31 stars 22 forks source link

getTec: connection time out #56

Closed tremou closed 2 months ago

tremou commented 3 months ago

Hi,

I am trying to run the getTec.py and I get a connection timed out. I attach the error below. This attempt is with the server="ftp://gnss.oma.be/gnss/products/IONEX/",prefix="ROBR". I also tried the server="ftp://cddis.gsfc.nasa.gov/gnss/products/ionex/",prefix="CODG" but I did not get better luck. Do you have any suggestions ?

Traceback (most recent call last):
  File "RMextract/examples/example_get_tec.py", line 15, in <module>
    tec=gt.getTEC(MS='FSgroup04.ms',ionexPath='./IONEXdata', timestep=300, timerange = [a, b], earth_rot=0,ha_limit=-1000, server="ftp://gnss.oma.be/gnss/products/IONEX/",prefix="ROBR")
  File "/soft/rm/lib64/python3.6/site-packages/RMextract/getTEC.py", line 89, in getTEC
    ionexf=ionex.getIONEXfile(time=date_parms,server=server,prefix=prefix,outpath=ionexPath)
  File "/soft/rm/lib64/python3.6/site-packages/RMextract/getIONEX.py", line 697, in getIONEXfile
    return _get_IONEX_file(time, server, prefix, outpath, overwrite)
  File "/soft/rm/lib64/python3.6/site-packages/RMextract/getIONEX.py", line 485, in _get_IONEX_file
    ftp = ftplib.FTP(ftpserver)
  File "/usr/lib64/python3.6/ftplib.py", line 119, in __init__
    self.connect(host)
  File "/usr/lib64/python3.6/ftplib.py", line 154, in connect
    source_address=self.source_address)
  File "/usr/lib64/python3.6/socket.py", line 724, in create_connection
    raise err
  File "/usr/lib64/python3.6/socket.py", line 713, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out
twillis449 commented 3 months ago

I don't know about the Belgian site but the access code for CDDIS is from somewhere back in the Stone Age. To access CDDIS you have to now

a) sign up and create an account for yourself at https://urs.earthdata.nasa.gov/ b) in your home directory create a file named .netrc which contains machine urs.earthdata.nasa.gov login xxxxxx password yyyyyy where xxxxxx and yyyyyy are the login name and password you created in step a

c) you will then need some Python 3 code similar to what is shown on the cddis page https://cddis.nasa.gov/Data_and_Derived_Products/CDDIS_Archive_Access.html

My variant using 'requests' is shown below based on the 'Download Single File' example shown in the left column of the above web page.

if sys.argv[1].find('cddis')> -1:
   url =  sys.argv[1]
   filename = sys.argv[2]
   r = requests.get(url)
   with open(filename, 'wb') as fd:
      for chunk in r.iter_content(chunk_size=1000):
         fd.write(chunk)
   fd.close()
   # is this a data file or stupid cddis html file returned when there's not actual data
   try:
     text= open(filename, 'r').readlines()
     if text[0].find('html') >= 0: # its a garbage html file and not a data file
       os.remove(filename)
       sys.exit(-3)
   except:
     file_stats = os.stat(filename)
     print('CDDIS returned a binary file with Byte size', file_stats.st_size )
     sys.exit(0)

And that's it - best of luck!

tremou commented 3 months ago

@twillis449 thanks so much for this. I will give it a try and I will post updates.

tremou commented 2 months ago

@twillis449 , that worked, great. I can close the issue. By the way , do you happen to know why CODG does not exist after 2022? I can see the CODG files here http://ftp.aiub.unibe.ch/CODE/ till 2022 but nothing after this

tremou commented 2 months ago

Oh I just realized that they are still there. Just the file name has changed after the GPS week 2238 (November 26, 2022)--> transition to long filename. Thanks again, Lilia

maaijke commented 2 months ago

HI Lilia, We are working on supporting the new filename format. In the mean time, if you have downloaded the latest master, you should still be able to use UQRG from the http://chapman.upc.es server for more recent dates

tremou commented 2 months ago

Thank you, @maaijke !