<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 <a href="https
Step1:  In order to use wget inside a Python program, you have to install it with pip
Step2:  Then, you have to import the wget package
Step3:  Now, let's develop a python function to be able to give the parameters of download. The code below is not complete and probably won't work under general circumstances, but the intention of it is simply to demonstrate the very first steps. The arguments of the function will be the following
Step4:  Now, check out the content of you folder in colab.
Get the date from computer time
In case your intention is to download the data on a daily basis, it is worth using your computer's date and time.
Step5:  Yesterday as an object can be defined using the timedelta, as follows
Step6:  Finally, you can download the data for the yesterday object.
Step7:  Unzip files in python
RINEX files are stored as zipped ones. Of course, you can unzip them in python. For that, it is necessary two modules
<ASSISTANT_TASK:>
Python Code:
!wget ftp://igs.bkg.bund.de/EUREF/BRDC/2022/033/BRDC00WRD_R_20220330000_01D_MN.rnx.gz
Explanation: <a href="https://colab.research.google.com/github/OSGeoLabBp/tutorials/blob/master/english/data_processing/lessons/download_gnss_data.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
Download navigational RINEX file from IGS data center
When processing raw GNSS data, it is more common to need RINEX navigation files for a specific day than for a period of time. IGS Data Centers store combined navigational files with free access. For combined data, it means that the data is combined from data recorded by a wide range of permanent stations all over the globe or in a particular region. It is possible to choose data from particular satellite constellations; however, mixed data can come across as the be the best option.
In this tutorial, it is presented how to manage the download of RINEX navigation files from an IGS regional data center using simple python scripts.
First off, let's download the mixed and combined navigation file for the day of year 33 in 2022 from IGS BKG data center. The data is stored at the ftp server: ftp://igs.bkg.bund.de/, in the remote directory /BRDC/2022/033/, and the file name is BRDC00WRD_R_20220410000_01D_MN.rnx.gz.
Having all the information, downloading is simply possible with wget. After typing "!wget", please add the full path of the file: ftp://igs.bkg.bund.de/EUREF/BRDC/2022/033/BRDC00WRD_R_20220330000_01D_MN.rnx.gz
End of explanation
pip install wget
Explanation: In order to use wget inside a Python program, you have to install it with pip:
End of explanation
import wget
Explanation: Then, you have to import the wget package:
End of explanation
from datetime import date
def download_rinex_navigation(ftp, rpath, my_date):
  doy = my_date.strftime('%j')
  year = my_date.strftime('%Y')
  url = ftp + rpath + year + '/' + doy + '/' + 'BRDC00WRD_R_' + year + doy + '0000_01D_MN.rnx.gz'
  try:
    name = wget.download(url)
  except URLError:
    return None
  return name
my_date = date(2022, 2, 2)
print(my_date)
download_rinex_navigation('ftp://igs.bkg.bund.de/', 'EUREF/BRDC/', my_date)
Explanation: Now, let's develop a python function to be able to give the parameters of download. The code below is not complete and probably won't work under general circumstances, but the intention of it is simply to demonstrate the very first steps. The arguments of the function will be the following:
ftp server name;
remote path;
date of data as datetime object.
The full path and the file name might be different on other data servers.
In the example below, the navigation data is downloaded for a specific day (2 February 2022). At first, the date function from the datetime module is used to convert year, month and day to a datetime object.
Then, the strftime function is used to convert the datetime object to a string. A wide range of formats is available (the script below, for example, gets the year and day of year).
End of explanation
from datetime import date, timedelta
Explanation: Now, check out the content of you folder in colab.
Get the date from computer time
In case your intention is to download the data on a daily basis, it is worth using your computer's date and time.
End of explanation
yesterday = date.today() - timedelta(days=1)
print(yesterday)
Explanation: Yesterday as an object can be defined using the timedelta, as follows:
End of explanation
download_rinex_navigation('ftp://igs.bkg.bund.de/', 'EUREF/BRDC/', yesterday)
Explanation: Finally, you can download the data for the yesterday object.
End of explanation
import gzip
import shutil
zipped = download_rinex_navigation('ftp://igs.bkg.bund.de/', 'EUREF/BRDC/', yesterday)
unzipped = zipped[:-3]
with gzip.open(zipped, 'rb') as f_in:
    with open(unzipped, 'wb') as f_out:
        shutil.copyfileobj(f_in, f_out)
Explanation: Unzip files in python
RINEX files are stored as zipped ones. Of course, you can unzip them in python. For that, it is necessary two modules: gzip and shutil:
End of explanation
<END_TASK>