SydroCmd Befehle

Aus TALSIM Docs
Diese Seite enthält Bearbeitungen, die nicht zum Übersetzen freigegeben sind.
Sprachen:


Extract

Extracts strings from each line within an ASCII file.

Argument Description
Key -extract
1 sourcefile
2 -string: search for a string

-pos: select a position
-split: split a string

3 either string or position as a number
4 -endstring, –endlen or -array
5 either a string or the word blank or a position as an integer, depending on the previous argument. With -split a comma-separated list of indices is required indicating which items should be saved.
6 targetfile

Example 1: extracts a string from each line within d:\temp\abc.txt which follows directly after "val=" and ends at the next blank.

SydroCmd -extract d:\temp\abc.txt -string val= -endstring blank d:\temp\extract.txt

Example 2: extracts a string from each line within d:\temp\abc.txt starting from position 15 with a length of 25 characters.

SydroCmd -extract d:\temp\abc.txt -pos 15 -endlen 25 d:\temp\extract.txt


Download

Downloads a file with a valid URL to the local machine.

Argument Description
Key -download or -downloadwget (the latter causes wget to be used for downloading)
1 URL (possibly with placeholders like {0})
2 Arguments separated by a comma filling the placeholders in the URL
3 targetfile

Example: Downloads a file from the NOAA data archive. Variables are the year, month, day.

SydroCmd -download http://nomads.ncdc.noaa.gov/modeldata/cfsv2_forecast_mm_9mon/{0}/{0}{1}/{0}{1}{2}/{0}{1}{2}00/flxf.01.{0}{1}{2}00.{3}{4}.avrg.grib.grb2  2016,12,02,2016,12 D:\temp\tmp.grb2


Replace

Replaces all strings with a new string within a file. Is able to handle current date information.

Argument Description
Key -replace
1 sourcefile
2 search string or DATE
3 replace string or a date in the format yyyyMMddHHmm or Now
4 targetfile (if not given, then sourcefile will be overwritten)


Date replacement

If the search string is the keyword DATE, dynamic date replacement takes place:

  • The replace string must then be a date in the format yyyyMMddHHmm or Now.
  • In the sourcefile, the placeholder to be replaced must be given as follows: {DATE|ValidFormatstring|ValidNumber,DateInterval}, where
    • ValidFormatstring: a date format string consisting of e.g. yyyy, MM, dd, HH, mm (see here for more options)
    • ValidNumber: 0, +2, -5 or any other integer (adds/subtracts the number of years, months, days, hours, minutes as given with the number)
    • DateIntervall= y, M, d, h, m (is used to add the ValidNumber to the date)
Example: {DATE|dd|+1,d} with a replace date of 30/12/2017 results in 31 (given date + 1 day, expressed as date (dd)).


Examples

Example 1: simple replacement of "hello" with "goodbye". The sourcefile will be overwritten.

SydroCmd –replace d:\temp\abc.txt hello goodbye

Example 2: with date information

In this example the first argument is the keyword DATE indicating that date information is used. If this string is found it will be replaced by the date given in the next argument (here 5/12/2016 00:00). In the file abc.txt the variable to be replaced must be given as follows: {DATE|yyyy|+1,y}. This means the result will be 2017, one year added to 2016.

SydroCmd –replace d:\temp\abc.txt DATE 201612050000 d:\temp\abcnew.txt

Example 2: with date information using Now

In this example the first argument is the keyword DATE indicating that date information is used. If this string is found it will be replaced by the date given in the next argument (here the keyword Now). In the file abc.txt the variable to be replaced must be given as follows: {DATE|yyyyMMdd|+1,M}. This means the result will be the current date plus one month.

SydroCmd –replace d:\temp\abc.txt DATE Now d:\temp\abcnew.txt


Zip

Compress files to a zip file.

Argument Description
Key -zip
1 source directory
2 zip filename
3 -pattern or –list
4 the pattern or a comma-separated list

Example 1: Compresses all files in directory d:\temp\ with the extension *.txt to the file myfile.zip

SydroCmd  –zip d:\temp\ myfile.zip –pattern *.txt

Example 2: Compresses a list of files in directory d:\temp\ with the extension *.txt to the file myzipfile.zip

SydroCmd -zip  d:\temp\ myzipfile.zip -list d:\mylist\file1.txt "d:\many files\newfile.doc"


UnZip

Unzips files from a zip file.

Argument Description
Key -unzip
1 output directory
2 source zip filename
3 -pattern or -list
4 the pattern or a comma-separated list

Example 1: Unzips all files in the zipfile d:\temp\myfile.zip with the pattern *.txt to d:\

SydroCmd -unzip d:\ d:\temp\myfile.zip -pattern *.txt

Example 2: Unzips a selection of files in d:\temp\myzipfile.zip to d:\

SydroCmd -unzip d:\ d:\temp\myzipfile.zip -list d:\mylist\file1.txt "d:\any directory\newfile.doc"

Example 3: Unzips all files in the zipfile d:\temp\myzipfile.zip to d:\

SydroCmd -unzip d:\ d:\temp\myzipfile.zip –pattern *.*

TimeSeries - GET

Retrieves a SydroTimeSeries object from the TalsimNGServer via REST interface.

Argument Description
Key timeseries
1 -get
2 Customer name, e.g. Test or KS_Gerstungen
3 User, e.g. Felix
4 Id of the time series, e.g. 406420
5 Startdate in yyyy-MM-dd HH:mm format or 0 for all entries from the beginning
6 Enddate in yyyy-MM-dd HH:mm format or 0 for all entries up to the end
7 Flag to specifiy which data are to be retrieved, e.g. 0, 1, etc.
8 Protocol, usually http
9 IP address, e.g. localhost or 10.0.0.5
10 Port. The default port is 8092
11 Filename. The destination file of the time series, e.g. d:\temp\timeseries.short.txt. No blank (space) is allowed in the path and name.

Example 1: The file timeseries.short.txt should be fetched from customer KS_Gerstungen. The time series has the Id 406420, the whole time series is desired. Only entries with the flag 0 are wanted. The server is located at 10.0.0.30. The result will be written to d:\temp\timeseries.long.txt.

SydroCmd.exe -timeseries -get KS_Gerstungen,hubert,406420,0,0,1,http,10.0.0.30,8092,d:\temp\timeseries.long.txt

Example 2: The timeseries with the Id 9998 is needed from customer TestApi.

SydroCmd -timeseries -get TestApi,hubert,9998,0,0,-1,http,localhost,8092,d:\temp\timeseries.short.txt


TimeSeries - POST

Uploads a SydroTimeSeries object to the TalsimNGServer via REST interface. All settings like Flag, SaveMetadata etc. are given in the SydroTimeSeries object itself.

Argument Description
Key timeseries
1 -post
2 Customer, e.g. Test or KS_Gerstungen
3 User, e.g. Felix
4 Id of the time series, e.g. 406420
8 Protocol, usually http
9 IP address, e.g. localhost or 10.0.0.5
10 Port. The default port is 8092
11 Source filename. The path to the time series file, e.g. d:\temp\timeseries.short.txt. No blank (space) is allowed in the path and name.

Example 1: The file timeseries.short.txt should be uploaded to customer TestAPI. The time series has the Id 9999 and the file is located at d:\temp\timeseries.short.txt.

SydroCmd.exe -timeseries -post TestApi,hubert,9999,http,localhost,8092,d:\temp\timeseries.short.txt

REST Service

Calls a REST Service URL to obtain its response.

Argument Description
Key REST
1 -rest
2 Timeout in milliseconds, e.g. 10000
3 Number of requests if a timed out occurs, e.g. 2
4 SaveTo, file where the response will be saved to, e.g. d:\temp\response.txt
8 Rest URL http://geoglows.ecmwf.int/api/HistoricSimulation/?reach_id=7042350&return_format=csv

Example 1: The GeoGLOWS REST Service is called to retrieve the historic simulation time series for reach_id = 7042350.

SydroCmd.exe -rest 10000 2 d:\temp\geoglows.csv "http://geoglows.ecmwf.int/api/HistoricSimulation/?reach_id=7042350&return_format=csv"