SydroCmd Befehle: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
(clarify parameters) |
||
(6 dazwischenliegende Versionen von 3 Benutzern werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
<languages/> | |||
<translate> | |||
<!--T:1--> | |||
{{Navigation|vorher=SydroCmd-Verzeichnisstruktur und Dateien|hoch=Arbeiten mit dem SydroCmd tool|nachher=Operationeller Einsatz von Talsim-NG}} | {{Navigation|vorher=SydroCmd-Verzeichnisstruktur und Dateien|hoch=Arbeiten mit dem SydroCmd tool|nachher=Operationeller Einsatz von Talsim-NG}} | ||
==Extract== | |||
==Extract== <!--T:2--> | |||
<!--T:3--> | |||
Extracts strings from each line within an ASCII file. | Extracts strings from each line within an ASCII file. | ||
{| class= | <!--T:4--> | ||
{| class=wikitable | |||
!Argument !! Description | |||
|- | |||
|Key || <code>-extract</code> | |||
|- | |||
|1 || sourcefile | |||
|- | |||
|2 || <code>-string</code>: search for a string | |||
<code>-pos</code>: select a position<br/> | |||
<code>-split</code>: split a string | |||
|- | |||
|3 || either string or position as a number | |||
|- | |- | ||
| | |4 || <code>-endstring</code>, <code>–endlen</code> or <code>-array</code> | ||
|<code>- | |||
|- | |- | ||
| | |5 || either a string or the word <code>blank</code> or a position as an integer, depending on the previous argument. With <code>-split</code> a comma-separated list of indices is required indicating which items should be saved. | ||
| | |||
|- | |- | ||
| | |6 || targetfile | ||
|< | |} | ||
<!--T:5--> | |||
'''Example 1''': extracts a string from each line within d:\temp\abc.txt which follows directly after "val=" and ends at the next blank. | |||
<!--T:6--> | |||
<pre> | |||
SydroCmd -extract d:\temp\abc.txt -string val= -endstring blank d:\temp\extract.txt | |||
</pre> | |||
<!--T:7--> | |||
'''Example 2''': extracts a string from each line within d:\temp\abc.txt starting from position 15 with a length of 25 characters. | |||
<!--T:8--> | |||
<pre> | |||
SydroCmd -extract d:\temp\abc.txt -pos 15 -endlen 25 d:\temp\extract.txt | |||
</pre> | |||
==Download== <!--T:9--> | |||
<!--T:10--> | |||
Downloads a file with a valid URL to the local machine. | |||
<!--T:11--> | |||
{| class=wikitable | |||
! Argument !! Description | |||
|- | |- | ||
| | |Key || <code>-download</code> or <code>-downloadwget</code> (the latter causes [https://www.gnu.org/software/wget/ wget] to be used for downloading) | ||
| | |||
|- | |- | ||
| | |1||URL (possibly with placeholders like <code>{0}</code>) | ||
|<code> | |||
|- | |- | ||
| | |2||Arguments separated by a comma filling the placeholders in the URL | ||
| | |||
|- | |- | ||
| | |3 || targetfile | ||
|targetfile | |||
|} | |} | ||
<!--T:12--> | |||
'''Example:''' Downloads a file from the NOAA data archive. Variables are the year, month, day. | |||
<!--T:13--> | |||
<pre> | |||
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 | |||
</pre> | |||
==Replace== <!--T:14--> | |||
<!--T:15--> | |||
Replaces all strings with a new string within a file. Is able to handle current date information. | |||
<!--T:16--> | |||
{| class=wikitable | |||
! Argument !! Description | |||
|- | |||
|Key || <code>-replace</code> | |||
|- | |||
|1||sourcefile | |||
|- | |||
|2||search string or <code>DATE</code> | |||
|- | |||
|3||replace string or a date in the format <code>yyyyMMddHHmm</code> or <code>Now</code> | |||
|- | |||
|4||targetfile (if not given, then sourcefile will be overwritten) | |||
|} | |||
===Date replacement=== <!--T:17--> | |||
<!--T:18--> | |||
If the search string is the keyword <code>DATE</code>, dynamic date replacement takes place: | |||
* The replace string must then be a date in the format <code>yyyyMMddHHmm</code> or <code>Now</code>. | |||
* In the sourcefile, the placeholder to be replaced must be given as follows: <code>{DATE|ValidFormatstring|ValidNumber,DateInterval}</code>, where | |||
** ValidFormatstring: a date format string consisting of e.g. yyyy, MM, dd, HH, mm (see [https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings 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: <code>{DATE|dd|+1,d}</code> with a replace date of 30/12/2017 results in <code>31</code> (given date + 1 day, expressed as date (<code>dd</code>)). | |||
===Examples=== <!--T:19--> | |||
<!--T:20--> | |||
'''Example 1''': simple replacement of "hello" with "goodbye". The sourcefile will be overwritten. | |||
<pre> | |||
SydroCmd –replace d:\temp\abc.txt hello goodbye | |||
</pre> | |||
<!--T:21--> | |||
'''Example 2''': with date information | |||
<!--T:22--> | |||
In this example the first argument is the keyword <code>DATE</code> 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: <code>{DATE|yyyy|+1,y}</code>. This means the result will be <code>2017</code>, one year added to 2016. | |||
<!--T:23--> | |||
<pre> | |||
SydroCmd –replace d:\temp\abc.txt DATE 201612050000 d:\temp\abcnew.txt | |||
</pre> | |||
<!--T:24--> | |||
'''Example 2''': with date information using <code>Now</code> | |||
<!--T:25--> | |||
In this example the first argument is the keyword <code>DATE</code> 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 <code>Now</code>). In the file abc.txt the variable to be replaced must be given as follows: <code>{DATE|yyyyMMdd|+1,M}</code>. This means the result will be the current date plus one month. | |||
:<code> | |||
<!--T:26--> | |||
: | <pre> | ||
SydroCmd –replace d:\temp\abc.txt DATE Now d:\temp\abcnew.txt | |||
</pre> | |||
== | ==Zip== <!--T:27--> | ||
{| class= | <!--T:28--> | ||
! | Compress files to a zip file. | ||
! | |||
<!--T:29--> | |||
{| class=wikitable | |||
! Argument !! Description | |||
|- | |- | ||
| | |Key || <code>-zip</code> | ||
|<code>- | |||
|- | |- | ||
| | |1||source directory | ||
| | |||
|- | |- | ||
| | |2||zip filename | ||
| | |||
|- | |- | ||
|4 | |3 || <code>-pattern</code> or <code>–list</code> | ||
| | |- | ||
|4||the pattern or a comma-separated list | |||
|} | |} | ||
<!--T:30--> | |||
: | '''Example 1''': Compresses all files in directory d:\temp\ with the extension *.txt to the file myfile.zip | ||
<pre> | |||
SydroCmd –zip d:\temp\ myfile.zip –pattern *.txt | |||
</pre> | |||
<!--T:31--> | |||
'''Example 2''': Compresses a list of files in directory d:\temp\ with the extension *.txt to the file myzipfile.zip | |||
<!--T:32--> | |||
! | <pre> | ||
! | SydroCmd -zip d:\temp\ myzipfile.zip -list d:\mylist\file1.txt "d:\many files\newfile.doc" | ||
</pre> | |||
==UnZip== <!--T:33--> | |||
<!--T:34--> | |||
Unzips files from a zip file. | |||
{| class=wikitable | |||
! Argument !! Description | |||
|- | |- | ||
| | |Key || <code>-unzip</code> | ||
|<code>- | |||
|- | |- | ||
| | |1||output directory | ||
| | |||
|- | |- | ||
| | |2||source zip filename | ||
| | |||
|- | |- | ||
| | |3 || <code>-pattern</code> or <code>-list</code> | ||
| | |||
|- | |- | ||
| | |4||the pattern or a comma-separated list | ||
| | |} | ||
|} | |||
<!--T:35--> | |||
'''Example 1''': Unzips all files in the zipfile d:\temp\myfile.zip with the pattern *.txt to d:\ | |||
<!--T:36--> | |||
<pre> | |||
SydroCmd -unzip d:\ d:\temp\myfile.zip -pattern *.txt | |||
</pre> | |||
<!--T:37--> | |||
'''Example 2''': Unzips a selection of files in d:\temp\myzipfile.zip to d:\ | |||
<!--T:38--> | |||
<pre> | |||
SydroCmd -unzip d:\ d:\temp\myzipfile.zip -list d:\mylist\file1.txt "d:\any directory\newfile.doc" | |||
</pre> | |||
: | |||
:: | |||
:: | |||
<!--T:39--> | |||
: | '''Example 3''': Unzips all files in the zipfile d:\temp\myzipfile.zip to d:\ | ||
<!--T:40--> | |||
<pre> | |||
: | SydroCmd -unzip d:\ d:\temp\myzipfile.zip –pattern *.* | ||
</pre> | |||
==TimeSeries - GET== <!--T:41--> | |||
<!--T:42--> | |||
Retrieves a SydroTimeSeries object from the TalsimNGServer via REST interface. | |||
{| class= | <!--T:43--> | ||
! | {| class=wikitable border=1 cellspacing=0 cellpadding=0 | ||
! | !Argument!!Description | ||
|- | |- | ||
| | |Key || timeseries | ||
| | |||
|- | |- | ||
| | |1 || <code>-get</code> | ||
| | |||
|- | |- | ||
| | |2||Customer name, e.g. <code>Test</code> or <code>KS_Gerstungen</code> | ||
| | |||
|- | |- | ||
| | |3||User, e.g. <code>Felix</code> | ||
|<code> | |||
|- | |- | ||
|5 | |4||Id of the time series, e.g. <code>406420</code> | ||
|the | |- | ||
|5||Startdate in <code>yyyy-MM-dd HH:mm</code> format or <code>0</code> for all entries from the beginning | |||
|- | |||
|6||Enddate in <code>yyyy-MM-dd HH:mm</code> format or <code>0</code> for all entries up to the end | |||
|- | |||
|7||Flag to specifiy which data are to be retrieved, e.g. <code>0</code>, <code>1</code>, etc. | |||
|- | |||
|8||Protocol, usually <code>http</code> | |||
|- | |||
|9||IP address, e.g. <code>localhost</code> or <code>10.0.0.5</code> | |||
|- | |||
|10||Port. The default port is <code>8092</code> | |||
|- | |||
|11||Filename. The destination file of the time series, e.g. <code>d:\temp\timeseries.short.txt</code>. '''No blank (space) is allowed in the path and name.''' | |||
|} | |} | ||
<!--T:44--> | |||
'''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. | |||
<!--T:45--> | |||
<pre> | |||
SydroCmd.exe -timeseries -get KS_Gerstungen,hubert,406420,0,0,1,http,10.0.0.30,8092,d:\temp\timeseries.long.txt | |||
</pre> | |||
<!--T:46--> | |||
'''Example 2''': The timeseries with the Id 9998 is needed from customer TestApi. | |||
<!--T:47--> | |||
<pre> | |||
SydroCmd -timeseries -get TestApi,hubert,9998,0,0,-1,http,localhost,8092,d:\temp\timeseries.short.txt | |||
</pre> | |||
== | ==TimeSeries - POST== <!--T:48--> | ||
{| class= | <!--T:49--> | ||
! | Uploads a SydroTimeSeries object to the TalsimNGServer via REST interface. All settings like Flag, SaveMetadata etc. are given in the SydroTimeSeries object itself. | ||
! | |||
<!--T:50--> | |||
{| class=wikitable border=1 cellspacing=0 cellpadding=0 | |||
!Argument!!Description | |||
|- | |- | ||
| | |Key || timeseries | ||
| | |||
|- | |- | ||
| | |1 || <code>-post</code> | ||
| | |||
|- | |- | ||
| | |2||Customer, e.g. <code>Test</code> or <code>KS_Gerstungen</code> | ||
| | |||
|- | |- | ||
| | |3||User, e.g. <code>Felix</code> | ||
|<code> | |||
|- | |- | ||
|5 | |4||Id of the time series, e.g. <code>406420</code> | ||
|the | |- | ||
|} | |8||Protocol, usually <code>http</code> | ||
|- | |||
|9||IP address, e.g. <code>localhost</code> or <code>10.0.0.5</code> | |||
|- | |||
|10||Port. The default port is <code>8092</code> | |||
|- | |||
|11||Source filename. The path to the time series file, e.g. <code>d:\temp\timeseries.short.txt</code>. '''No blank (space) is allowed in the path and name.''' | |||
|} | |||
<!--T:51--> | |||
'''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. | |||
<!--T:52--> | |||
<pre> | |||
SydroCmd.exe -timeseries -post TestApi,hubert,9999,http,localhost,8092,d:\temp\timeseries.short.txt | |||
</pre> | |||
==REST Service== <!--T:53--> | |||
<!--T:54--> | |||
Calls a REST Service URL to obtain its response. | |||
<!--T:55--> | |||
{| class=wikitable border=1 cellspacing=0 cellpadding=0 | |||
!Argument!!Description | |||
|- | |||
|Key || REST | |||
|- | |||
|1 || <code>-rest</code> | |||
|- | |||
|2||Timeout in milliseconds, e.g. <code>10000</code> | |||
|- | |||
|3||Number of requests if a timed out occurs, e.g. <code>2</code> | |||
|- | |||
|4||SaveTo, file where the response will be saved to, e.g. <code>d:\temp\response.txt</code> | |||
|- | |||
|8||Rest URL <code>http://geoglows.ecmwf.int/api/HistoricSimulation/?reach_id=7042350&return_format=csv</code> | |||
|- | |||
|} | |||
<!--T:56--> | |||
'''Example 1''': The GeoGLOWS REST Service is called to retrieve the historic simulation time series for reach_id = 7042350. | |||
: | |||
<!--T:57--> | |||
<pre> | |||
SydroCmd.exe -rest 10000 2 d:\temp\geoglows.csv "http://geoglows.ecmwf.int/api/HistoricSimulation/?reach_id=7042350&return_format=csv" | |||
</pre> | |||
</translate> |
Aktuelle Version vom 3. Mai 2021, 16:21 Uhr
Extract
Extracts strings from each line within an ASCII file.
Argument | Description |
---|---|
Key | -extract
|
1 | sourcefile |
2 | -string : search for 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
orNow
. - 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 in31
(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"