User Tools

Site Tools


wiki:grass_hpc

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

wiki:grass_hpc [2017/12/05 22:53] (current)
Line 1: Line 1:
 +====== GRASS in the YALE-HPC ======
 +===== Start GRASS in non-interactively mode in a pre-existing location =====
 +
 +For this exercise we are going to use the $HOME/​ost4sem/​grassdb/​europe and $HOME/​ost4sem/​exercise/​basic_adv_gdalogr/​input_proj.tif file if do not have please download ​
 +
 +  mkdir -p $HOME/​ost4sem/​grassdb/​
 +  cd $HOME/​ost4sem/​grassdb/​
 +  wget https://​dl.dropboxusercontent.com/​u/​29337496/​europe.tar.gz
 +  tar xvzf europe.tar.gz
 +  wget https://​dl.dropboxusercontent.com/​u/​29337496/​input_proj.tif
 +  mkdir -p  $HOME/​ost4sem/​exercise/​basic_adv_gdalogr/​
 +  mv  $HOME/​input_proj.tif $HOME/​ost4sem/​exercise/​basic_adv_gdalogr/​
 +\\
 +If you are using qsub in a HPC you should run GRASS scripts in a non-interactively from outside of a GRASS session by setting the GRASS_BATCH_JOB environment variables.\\
 +When GRASS is started with this environment variables set it will automatically run the contents of the script given in the variable, then close the GRASS session when complete. ​
 +
 +<code bash| enter_grass.sh >
 +
 +#!/bin/bash
 +
 +GISDBASE=$(dirname $(dirname ​ $1))
 +LOCATION_NAME=$(basename $(dirname ​ $1))
 +MAPSET=$(basename ​ $1) 
 +
 +echo Enter in GRASS using GISDBASE = $GISDBASE, LOCATION = $LOCATION_NAME,​ MAPSET = $MAPSET  ​
 +
 +echo "​GISDBASE:​ $GISDBASE" ​                > $HOME/​.grass7/​grass$$
 +echo "​LOCATION_NAME:​ $LOCATION_NAME" ​     >> $HOME/​.grass7/​grass$$
 +echo "​MAPSET:​ $MAPSET" ​                   >> $HOME/​.grass7/​grass$$
 +echo "​GRASS_GUI:​ text" ​                   >> $HOME/​.grass7/​grass$$
 +
 +# path to GRASS settings file
 +export GISRC=$HOME/​.grass7/​grass$$
 +export GRASS_PYTHON=python
 +export GRASS_MESSAGE_FORMAT=plain
 +export GRASS_PAGER=cat
 +export GRASS_WISH=wish
 +export GRASS_ADDON_BASE=$HOME/​.grass7/​addons
 +export GRASS_VERSION=7.0.0beta1
 +export GISBASE=/​usr/​local/​cluster/​hpc/​Apps/​GRASS/​7.0.0beta1/​grass-7.0.0beta1
 +export GRASS_PROJSHARE=/​usr/​local/​cluster/​hpc/​Libs/​PROJ/​4.8.0/​share/​proj/​
 +export PROJ_DIR=/​usr/​local/​cluster/​hpc/​Libs/​PROJ/​4.8.0
 +
 +export PATH="​$GISBASE/​bin:​$GISBASE/​scripts:​$PATH"​
 +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"​$GISBASE/​lib"​
 +export GRASS_LD_LIBRARY_PATH="​$LD_LIBRARY_PATH"​
 +export PYTHONPATH="​$GISBASE/​etc/​python:​$PYTHONPATH"​
 +export MANPATH=$MANPATH:​$GISBASE/​man
 +export GIS_LOCK=$$
 +export GRASS_OVERWRITE=1
 +
 +echo "########################"​
 +echo Welcome to GRASS 
 +echo "########################"​
 +
 +g.gisenv  ​
 +
 +echo "########################"​
 +echo Start to use GRASS comands
 +echo "########################"​
 +
 +</​code>​
 +
 +==== How to use it ======
 +
 +Download or copy/paste the file in your editor and save as enter_grass.sh.\\
 +Load the script with the command source and specify the mapset.
 +
 +  wget https://​dl.dropboxusercontent.com/​u/​29337496/​enter_grass.sh
 +  source enter_grass.sh ​ $HOME/​ost4sem/​grassdb/​europe/​PERMANENT
 +
 +You can test if you are GRASS by using a grass command
 +
 +  g.list rast
 +
 +   
 +===== Start GRASS in non-interactively mode and create a location =====
 +In case you want create a location on the flight based on a pre-existing georeferenced dataset and keep using grass command for that file you can use this file. 
 +
 +<code bash| create_location.sh >
 +
 +
 +#!/bin/bash
 +
 +export GISDBASE=$1
 +export LOCATION=$2
 +export file=$3
 +
 +export filename=$(basename ​ $file .tif)
 +
 +rm -rf  $GISDBASE/​$LOCATION $GISDBASE/​loc_tmp
 +
 +mkdir -p  $GISDBASE/​loc_tmp/​tmp
 +
 +echo "​LOCATION_NAME:​ loc_tmp" ​                                                      > $HOME/​.grass7/​rc_$filename
 +echo "​GISDBASE:​ /​dev/​shm" ​                                                         >> $HOME/​.grass7/​rc_$filename
 +echo "​MAPSET:​ tmp" ​                                                                >>​ $HOME/​.grass7/​rc_$filename
 +echo "​GRASS_GUI:​ text" ​                                                            >>​ $HOME/​.grass7/​rc_$filename
 +
 +# path to GRASS settings file
 +export GISRC=$HOME/​.grass7/​rc_$filename
 +export GRASS_PYTHON=python
 +export GRASS_MESSAGE_FORMAT=plain
 +export GRASS_PAGER=cat
 +export GRASS_WISH=wish
 +export GRASS_ADDON_BASE=$HOME/​.grass7/​addons
 +export GRASS_VERSION=7.0.0beta1
 +export GISBASE=/​usr/​local/​cluster/​hpc/​Apps/​GRASS/​7.0.0beta1/​grass-7.0.0beta1
 +export GRASS_PROJSHARE=/​usr/​local/​cluster/​hpc/​Libs/​PROJ/​4.8.0/​share/​proj/​
 +export PROJ_DIR=/​usr/​local/​cluster/​hpc/​Libs/​PROJ/​4.8.0
 +
 +export PATH="​$GISBASE/​bin:​$GISBASE/​scripts:​$PATH"​
 +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"​$GISBASE/​lib"​
 +export GRASS_LD_LIBRARY_PATH="​$LD_LIBRARY_PATH"​
 +export PYTHONPATH="​$GISBASE/​etc/​python:​$PYTHONPATH"​
 +export MANPATH=$MANPATH:​$GISBASE/​man
 +export GIS_LOCK=$$
 +export GRASS_OVERWRITE=1
 +
 +rm -rf  $GISDBASE/​$LOCATION
 +
 +echo start importing ​
 +r.in.gdal in=$file ​  ​out=$filename ​ location=$LOCATION
 +
 +g.mapset mapset=PERMANENT ​ location=$LOCATION
 +
 +rm -rf  $GISDBASE/​loc_tmp
 +
 +echo "########################"​
 +echo  Welcome to GRASS
 +echo "########################"​
 +
 +g.gisenv ​
 +
 +echo "########################"​
 +echo Start to use GRASS comands
 +echo "########################"​
 +
 +</​code>​
 +
 +==== How to use it ======
 +
 +Download or copy/paste the file in your editor and save as create_location.sh.\\
 +Load the script with the command source and specify the grass database location_name and file to import.
 +
 +  source create_location.sh /dev/shm location $HOME/​ost4sem/​exercise/​basic_adv_gdalogr/​input_proj.tif  ​
 +
 +You can test if you are GRASS by using a grass comand
 +
 +  g.list rast
 +
 +===== Start GRASS in non-interactively and perform an analysis =====
 +
 +<code bash| my_grass_analysis.sh >
 +
 +wget https://​dl.dropboxusercontent.com/​u/​29337496/​create_location.sh
 +source create_location.sh /dev/shm location $HOME/​ost4sem/​exercise/​basic_adv_gdalogr/​input_proj.tif  ​
 +r.report input_proj
 +
 +</​code>​
 +
 +==== How to use it ======
 +Copy/Paste the file in your editor and save as my_grass_analysis.sh.\\
 +
 +  bash my_grass_analysis.sh
  
wiki/grass_hpc.txt ยท Last modified: 2017/12/05 22:53 (external edit)