Installation

Mac OS

First ensure you have following prequisites:

  • Python3.5 +

  • HomeBrew

cd scripts/install && sh install_mac.sh

Ubuntu

First ensure you have following prequisites:

  • Python3.5 +

  • wget

cd scripts/install && sh install_ubuntu.sh

Python

Install the python package by:

python setup.py install

Installing the Database

The script under ./scripts/install will perform the following:

1: Adds the following to the file /etc/postgresql/13/main/environment to enable rasters, for more info see PostGIS installation page under 2.2. Configuring raster

POSTGIS_ENABLE_OUTDB_RASTERS=1
POSTGIS_GDAL_ENABLED_DRIVERS=ENABLE_ALL
  1. Then it will restart the PostGIS service using:

sudo service postgresql restart

3. Creates your tables, our main one called snowex, and another called test for running small unittests on.

sudo -u <username> psql -c "CREATE DATABASE snowex; CREATE DATABASE test;"
  1. Installs the post gis extensions via:

psql test -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_raster;"
psql snowex -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_raster;"
  1. Create a users ubuntu and snow

  2. Make user snow a read only user

  3. Installs the python package snowex_db

Notes for Remote Access

  • To allow access to your remote database modify ‘/etc/postgresql/13/main/postgresql.conf’

    by uncommenting and setting the following:

listen_addresses = '*'
  • Further to add remote access add the following to /etc/postgresql/13/main/postgresql.conf:

    1. To add access from the unrestricted access to jupyter hub user add the line below:

    host    snowex          ubuntu          <IP RANGE>           trust
    
    1. To add the read only user access from anywhere add the following:

    host    snowex          snow            0.0.0.0/0               md5
    

Install From Source

The sources for snowex_db can be downloaded from the Github repo.

You can either clone the public repository:

$ git clone git://github.com/SnowEx/snowex_db

Once you have a copy of the source, you can install it with:

$ python3 setup.py install

Once you install the python package, you can populate the database.

Populating the Database

This is only required for the admin user setting up the database. Once the data is in the database any user will be able to access it.

1. Setup an earth login account at NSIDC. Then make the following file via:

echo 'machine urs.earthdata.nasa.gov login <uid> password <password>' >> ~/.netrc
  1. Edit the file ~/.netrc and replace the above with your actual credentials to the earth login

  2. Protect that file via:

chmod 0600 ~/.netrc
  1. Download the data by running all the shell scripts under ./scripts/download

5. In the ./scripts/upload folder, there is a collection of scripts to upload data to the database. Once the data is on the disk, a user can run the scripts individually or all together.

cd scripts/upload

# Run individually
python add_profiles.py

# or all together...
python run.py

Note: The run.py script has a few questions to ask for a couple inputs that are required to run upload the data. Additionally, running the run.py file can take a few hours.

Additional Note: Running the scripts individually does not consider whether the data is in the db. So running a script twice will result in that data being uploaded twice!