University of Colorado
One of the most powerful features of the Earth System Grid Federation (ESGF) is the capability to generate scripts to download files for arbitrary query parameters, that can download more than one file from one data node. The script generator is even able to create several scripts in one request if data from several data nodes are desired. Currently, these scripts are based on the wget command, which is typically installed by default on nearly all modern laptops and desktops. Before downloading the data, the script will prompt the user for their OpenID and password, which will be used to retrieve a short-lifetime digital certificate from the ESGF site where the user registered. This certificate (which is valid for only 72 hours) is passed by Wget to the server holding the data, as a proof of the user's identity.
ESGF Wget scripts are smart enough to recognize if files have already been downloaded and skip them. If the download was interrupted before having finished, simply run the script in the same directory again. The script will continue the download then. Even the download of a partially downloaded file will be continued.
ESGF Wget scripts can also help you to recognize if a new version of the downloaded data is available in ESGF. After download, keep the script and run it again with the option -u to search for new versions. The download itself is not repeated then but the download script is created again and is compared with the old one.
Before being able to execute a Wget download script, the following pre-requisites must be satisfied:
Login to an ESGF portal, perform a search and add all datasets you desire to your DataCart. Go to your DataCart.
Many CMIP5 datasets contain several hundreds of files, some even more than thousand. If you want to download CMIP5 data, narrow your search with help of the text field (arrow "N"). In detail, take down the names of the variables you need delimited by a blank and press the Apply button. This affects also files inside a dataset and usually reduces the number of download files considerably. On the contrary, the categories "Variable", "Variable Long Name" and "CF Standard Name" in the search form only influence the dataset selection, not the selection of files inside a dataset.
Figure 1: Utilization of the DataCart for Wget script creation
In the DataCart, several links "WGET Script" are shown, for every dataset one (e.g. arrow "1") and additionally one for all selected datasets (arrow "all"). To select a dataset click on the little square left of the dataset. The link at every dataset allows creation of a separate Wget script for the one dataset only. After clicking on one of these links, the download manager of your browser pops up a control window for script download. In the case of Chrome, the downloaded script will appear at the bottom of the browser. Download the script to your local machine now.
The file name wget-############.sh of the downloaded script begins with wget- followed by a time stamp, a number and the extension .sh. The script is a UNIX Shell script and may be edited with a text editor. In this way, you may shorten the list of download files, e.g. if you do not need data for all available periods. Do not change other parts of the script.
Open a terminal window. Mac users can find a terminal icon in the Launchpad. If Oracle Java is available, run the script in the default mode:
Otherwise run the script with option -H to avoid use of Java and locally downloaded certificates.
bash wget-##############.sh -H
The bash command in front of the script name opens the right Shell for running the script. The script will ask you for your OpenID and password. Only in default mode and if you run several downloads from the same ESGF data node, this will be skipped and a locally stored credential will be used for authentication instead.
Wget scripts can also be generated with help of the ESGF Search RESTful API, which can be used by a script or by simply typing-in a URL augmented with commands, which are interpreted by an ESGF index node (portal). For example, the following URL will generate a Wget script that match all CMIP5 files in the ESGF, across all sites:
Nevertheless, this script will contain download links for only the first 1000 files, the recent limit for the number of download files. CMIP5 has much more. For generation of a useful script, more selection commands are needed. For example,
will generate a script for download of all surface temperature files for experiment decadal2000 across all CMIP5 models.
The blanks in the category name (facet name) you may know from the CoG surface, for example in "Time Frequency", have to be replaced by underscores:
Selection commands are delimited by an ampersand and interpreted in the sense of a logical AND, except those specifying the same category. For example, in
the category variable is used twice. These two selection commands are interpreted in the sense of a logical OR, in detail:
experiment=decadal2000 AND (variable=tas OR variable=tasmax)
A script will be generated for download of all decadal2000 files containing the variables tas or tasmax, i.e. both variables will be downloaded in one script run.
Use as much selection commands as possible and useful in your case to reduce the number of download files. For some power users, thousand files in one script run may not be suffient. They can use the limit command to raise the limit for the number of download files, e.g.:
This additional command would enable the example URLs above (except the first) to create a script with a complete file list. Please note that a limit of more than 10000 files will generally not be accepted.
Another nice feature for users who need many data files is preservation of the directory structure with the command download_structure. This command can be used to define a directory tree at the user's local machine. If you want to copy the files to a directory tree which is also used in ESGF for CMIP5 data, utilize the following command:
Accordingly the same for CORDEX:
Last an example for a complete URL with preservation of the CMIP5 directory tree:
ESGF Wget scripts can be run with options. For an overview of possible options type-in
bash wget-##############.sh -h
(-h for help). Different options can be combined. The following options are important:
This option causes the script to send more than the usual response to standard output. Use
bash wget-##############.sh -H -d
if you have problems with option -H since scripts run with option -H are nearly silent. They don't even send useful error messages.
Caution: Do not send your standard output to the user support mailing list firstname.lastname@example.org because option -d may cause the script to print your password! Everyone can subscribe to email@example.com and your post will be distributerd to every subscriber.
Since many users have problems with Java and certificates on their local machines, the option -H was developed to avoid use of Java and locally stored certificates. Instead, your OpenID and password are sent with help of a Wget command. Your password is encrypted with SSL (or TLS if you have additionally switched to TLS with option -T). Without option -H, a local credential is created and sent to ESGF servers for the user's authentication but Oracle Java 1.7+ is needed for this purpose.
This option disables check of server certificates. This has nothing to do with locally stored certificates and option -H. On the contrary, in a Grid as ESGF authentication is needed in two directions: The user has to authenticate herself/himself at the server and the server has to authenticate itself at the user's local machine. You may use
bash wget-##############.sh -i
to switch off the check of the server certificate by your local machine. This is sometimes helping in case of an expired server certificate. Before use of this option, you should ask your system administrator if you are allowed to do this.
After download, the Wget script calculates a checksum for the freshly downloaded file. If -p is not set, downloaded files will usually be deleted if their checksum does not match the value in the script's file list. Afterwards, download will be repeated until it succeeds. This feature shall automatically correct alterations in the bitstream of the downloaded file. Use the -p option to suppress file deletion.
bash wget-##############.sh -p
The downloaded file will then be preserved despite checksum mismatch. This option does not suppress checksum comparison. In case the calculated checksum of a downloaded file does not match the checksum in the download file list, a warning will be thrown. This option may be useful if the checksum stored in the data node's metadata is outdated (seldom but already happened).
Network traffic between ESGF servers and the user's local machine is usually encrypted using SSL (Secure Sockets Layer). The option -T switches to TLS v1 (Transport Layer Security) instead of SSL.
The option -u is used to repeat the search and find changes in the download file list. In more detail, the Wget script is again generated and compared with the old, locally stored Wget script. New available files are listed as well as new versions of previously downloaded files since the checksum of a replaced file differs from that of the old version. Other changes in the script are also shown. If a modification is detected, the Wget script will be updated and the previous version will be stored at my_wget_script.old.# where # is just a running index. This option needs the UNIX diff program. Data files will not be downloaded.