Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thredds script #406

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions scripts/thredds/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The script in this folder will create a catalog.xml output that can be
used by the thredds server. This script is run every day and will update
the thredds server to show the latest data available.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?example useage (could you paste the crontab here?)

Link to live website as example

Is there a Dockerfile for the server?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to data use policy here, and to the published webpage


The script writes the catalog.xml to a folder that is similair to the
example 4.6.8 thredds server.

This script is used with cronjob and the following little script:

```
#!/bin/bash

cd /home/ubuntu
./thredds.sh > thredds/catalog.xml
/usr/sbin/service tomcat8 restart
```

The output of the script can be found at:
https://terraref.ncsa.illinois.edu/thredds/
88 changes: 88 additions & 0 deletions scripts/thredds/thredds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash

dataset() {
FOLDER="$1"
DSPATH="$2"
TITLE="$3"

echo " <dataset name=\"${TITLE}\" ID=\"${TITLE}\">"

IFS=$'\n'
LAST_DATE=""
LAST_TIME=""

FILES=$( find ${FOLDER} -name \*.nc | sort )
#FILES=$( cat ncfiles.txt | sort )
for X in ${FILES}; do
# remove leading whitespace, and extract information
X="${X#${FOLDER}}"
X="${X//[[:space:]]/}"
X="${X:1}"
echo "$X"

DATE=$( echo "$X" | cut -d "/" -f1 )
if [ "$DATE" != "$LAST_DATE" ]; then
if [ "$LAST_DATE" != "" ]; then
echo ' </dataset>'
echo ' </dataset>'
fi
LAST_TIME=""
LAST_DATE="$DATE"
echo " <dataset name=\"${DATE}\" ID=\"${DATE}\">"
fi

TIME=$( echo "$X" | cut -d "/" -f2)
if [ "$TIME" != "$LAST_TIME" ]; then
if [ "$LAST_TIME" != "" ]; then
echo ' </dataset>'
fi
LAST_TIME="$TIME"
NAME=$( echo "$TIME" | cut -d "_" -f3 | tr "-" ":" | cut -d ":" -f 1,2 )
echo " <dataset name=\"${NAME}\" ID=\"${TIME}\">"
fi

NAME=$( echo "$X" | cut -d "/" -f3 )
echo " <dataset name=\"${NAME}\" ID=\"${X}\" urlPath=\"${DSPATH}${X}\" serviceName=\"all\">"
echo ' </dataset>'
done
echo ' </dataset>'
echo ' </dataset>'
echo ' </dataset>'
}

# ----------------------------------------------------------------------
# HEADER
# ----------------------------------------------------------------------
cat << EOF
<?xml version="1.0" encoding="UTF-8"?>
<catalog name="THREDDS Server Default Catalog : You must change this to fit your server!"
xmlns="http://www.unidata.ucar.edu/namespaces/thredds/InvCatalog/v1.0"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.unidata.ucar.edu/namespaces/thredds/InvCatalog/v1.0
http://www.unidata.ucar.edu/schemas/thredds/InvCatalog.1.0.6.xsd">

<service name="all" base="" serviceType="compound">
<service name="odap" serviceType="OpenDAP" base="/thredds/dodsC/" />
<service name="dap4" serviceType="DAP4" base="/thredds/dap4/" />
<service name="http" serviceType="HTTPServer" base="/thredds/fileServer/" />
<!--service name="wcs" serviceType="WCS" base="/thredds/wcs/" /-->
<!--service name="wms" serviceType="WMS" base="/thredds/wms/" /-->
<service name="ncss" serviceType="NetcdfSubset" base="/thredds/ncss/" />
</service>

<datasetRoot path="uamac_hs" location="/home/sites/ua-mac/Level_1/vnir_netcdf"/>

<dataset name="TERRA" ID="TERRA">
EOF

# ----------------------------------------------------------------------
# DATASETS
# ----------------------------------------------------------------------
dataset "/home/sites/ua-mac/Level_1/vnir_netcdf" "uamac_hs" "UAMac Hyperspectral"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are steps for adding

dataset "/home/sites/ua-mac/Level_1/envlog_netcdf" "uamac_env" "UAMac Environmental Logger"


# ----------------------------------------------------------------------
# FOOTER
# ----------------------------------------------------------------------
echo ' </dataset>'
echo '</catalog>'