Resources.java [src/java/m/watershed] Revision: default Date:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package m.watershed;
import csip.Config;
import csip.api.server.PayloadParameter;
import csip.api.server.ServiceException;
import csip.annotations.Resource;
import static csip.annotations.ResourceType.EXECUTABLE;
import static csip.annotations.ResourceType.OUTPUT;
import static csip.annotations.ResourceType.REFERENCE;
import static m.watershed.Resources.*;
/**
*
* @author holm,od
*/
@Resource(file = "${watershed.taudem.d8flowdir}", type = EXECUTABLE, id = D8)
@Resource(file = "${watershed.taudem.pitremove}", type = EXECUTABLE, id = PITREMOVE)
@Resource(file = "${watershed.taudem.dinfflowdir}", type = EXECUTABLE, id = DINF)
@Resource(file = "${watershed.taudem.aread8}", type = EXECUTABLE, id = AREAD8)
@Resource(file = "${watershed.taudem.gridnet}", type = EXECUTABLE, id = GRIDNET)
@Resource(file = "${watershed.taudem.peukerdouglas}", type = EXECUTABLE, id = PDOUG)
@Resource(file = "${watershed.taudem.areadinf}", type = EXECUTABLE, id = AREADINF)
@Resource(file = "${watershed.taudem.dropanalysis}", type = EXECUTABLE, id = DROP)
@Resource(file = "${watershed.taudem.streamnet}", type = EXECUTABLE, id = STREAMNET)
@Resource(file = "${watershed.taudem.d8hdisttostrm}", type = EXECUTABLE, id = D8STREAMDIST)
@Resource(file = "${watershed.taudem.moveoutletstostrm}", type = EXECUTABLE, id = MOVEOUTLET)
@Resource(file = "${watershed.taudem.threshold}", type = EXECUTABLE, id = THRESHOLD)
@Resource(file = LOCATION_PY + "/zonalstats.py", id = ZONALSTATS)
@Resource(file = LOCATION_PY + "/zonalstats_new.py", id = ZONALSTATS_NEW)
@Resource(file = LOCATION_PY + "/zonalstats_mean.py", id = ZONALSTATS_MEAN)
@Resource(file = LOCATION_PY + "/zonalstats_mamc.py", id = ZONALSTATS_MAMC)
@Resource(file = LOCATION_PY + "/zonalstats_max.py", id = ZONALSTATS_MAX)
@Resource(file = LOCATION_PY + "/zonalstats_pts.py", id = ZONALSTATS_PTS)
@Resource(file = LOCATION_PY + "/readmm.py", id = READMM)
@Resource(file = LOCATION_PY + "/clean.py", id = CLEAN)
@Resource(file = LOCATION_PY + "/LS.py", id = LS)
@Resource(file = LOCATION_PY + "/slope_length.py", id = SLOPELENGTH)
@Resource(file = LOCATION_PY + "/cfactor.py", id = CFACTOR)
@Resource(file = LOCATION_PY + "/curve_number.py", id = CURVENUMBER)
@Resource(file = LOCATION_PY + "/grid_info.py", id = GRID_INFO)
@Resource(file = "${watershed.mpi}", type = REFERENCE, id = MPI)
@Resource(file = "${watershed.gdal}", type = REFERENCE, id = GDAL)
@Resource(file = "${watershed.gdaltranslate}", type = REFERENCE, id = GDALTRANSLATE)
@Resource(file = "${watershed.gdalraster}", type = REFERENCE, id = GDALRASTER)
@Resource(file = "${watershed.gdaldem}", type = REFERENCE, id = GDALDEM)
@Resource(file = "${watershed.gdalinfo}", type = REFERENCE, id = GDALINF)
@Resource(file = "${watershed.gdalpolygonize}", type = REFERENCE, id = GDALPOLYGONIZE)
@Resource(file = "${watershed.gdalcalc}", type = REFERENCE, id = GDALCALC)
@Resource(file = "${watershed.gdalmerge}", type = REFERENCE, id = GDALMERGE)
@Resource(file = "${watershed.gdalbuildvrt}", type = REFERENCE, id = GDALBUILDVRT)
@Resource(file = "${watershed.ogr}", type = REFERENCE, id = OGR)
@Resource(file = "${watershed.ogrinfo}", type = REFERENCE, id = OGRINFO)
@Resource(file = "${watershed.python}", type = REFERENCE, id = PYTHON)
@Resource(file = "${watershed.python2}", type = REFERENCE, id = PYTHON2)
@Resource(file = "${watershed.python3}", type = REFERENCE, id = PYTHON3)
//@Resource(file = "*.dat *.txt *.shp *.shx *.dbf *.prj *.csv *.tif *.json *.vrt *.kml *.geojson", type = OUTPUT)
//@Resource(file = "*.dat *.txt *.shp *.shx *.dbf *.prj", type = OUTPUT)
public abstract class Resources {
//public static String LOCATION = "/bin/lin-amd64_TD537"; // org TauDEM v5.3.7
//public static String LOCATION = "/bin/lin-amd64_TDCG"; // cyberGIS
public static final String LOCATION_TAU = "/bin/lin-amd64_TDMX"; // cyberGIS & TauDEM Mix
public static final String LOCATION_PY = "/python";
// public static final String LOCATION_MNT_DATA1 = "/mnt/csip-watershed";
public static final String LOCATION_MNT_DATA1
= Config.getString("watershed.data.path", "/mnt/csip-watershed");
// public static final String LOCATION_MNT_CSIP_DEM = "/mnt/csip-dem";
public static final String LOCATION_MNT_CSIP_DEM
= Config.getString("watershed.dem.path", "/mnt/csip-dem");
//
public static final String MPI = "mpirun"; //mpiexec for Windows !!!!!!!
public static final String GDAL = "gdalwarp";
public static final String GDALDEM = "gdaldem";
public static final String GDALINF = "gdalinfo";
public static final String GDALTRANSLATE = "gdal_translate";
public static final String GDALRASTER = "gdal_rasterize";
public static final String GDALPOLYGONIZE = "gdal_polygonize.py";
public static final String GDALCALC = "gdal_calc.py";
public static final String GDALMERGE = "gdal_merge.py";
public static final String GDALBUILDVRT = "gdalbuildvrt";
public static final String OGR = "ogr2ogr";
public static final String OGRINFO = "ogrinfo";
public static final String PYTHON = "python";
public static final String PYTHON2 = "python2";
public static final String PYTHON3 = "python3";
public static final String PITREMOVE = "pitremove";
public static final String D8 = "d8flowdir";
public static final String AREAD8 = "aread8";
public static final String GRIDNET = "gridnet";
public static final String PDOUG = "peukerdouglas";
public static final String DINF = "dinfflowdir";
public static final String AREADINF = "areadinf";
public static final String DROP = "dropanalysis";
public static final String STREAMNET = "streamnet";
public static final String D8STREAMDIST = "d8hdisttostrm";
public static final String MOVEOUTLET = "moveoutletstostrm";
public static final String THRESHOLD = "threshold";
public static final String ZONALSTATS = "zonalstats";
public static final String ZONALSTATS_NEW = "zonalstats_new";
public static final String ZONALSTATS_MEAN = "zonalstats_mean";
public static final String ZONALSTATS_MAMC = "zonalstats_mamc";
public static final String ZONALSTATS_MAX = "zonalstats_max";
public static final String ZONALSTATS_PTS = "zonalstats_pts";
public static final String READMM = "readmm";
public static final String CLEAN = "clean";
public static final String LS = "LS";
public static final String SLOPELENGTH = "slope_length";
public static final String CFACTOR = "cfactor";
public static final String CURVENUMBER = "curve_number";
public static final String GRID_INFO = "grid_info";
public static final String DDM = "row";
static final String MPI_THREADS = "mpi.cores";
/**
* get the # threads for MPI calls.
*
* @param parameter
* @return
* @throws ServiceException
*/
public static int mpiThreads(PayloadParameter parameter) throws ServiceException {
int threads = Runtime.getRuntime().availableProcessors() / 2;
threads = threads + (threads / 2); // using 75% of physical cores
threads = Config.getInt(MPI_THREADS, threads); // config
if (parameter != null) {
threads = parameter.getInt(MPI_THREADS, threads); // payload
}
return threads;
}
}