Skip to content

Commit

Permalink
Add "--sort" parameter for sorting by result columns
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Mar 14, 2018
1 parent d549286 commit 7c65680
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -9,6 +9,7 @@ development
to appropriate text representions from metadata files
- Update "Usage" section in README
- Add humanized representation for "forecast" mode
- Add "--sort" parameter for sorting by result columns

2018-03-14 0.4.0
================
Expand Down
31 changes: 31 additions & 0 deletions README.rst
Expand Up @@ -216,6 +216,37 @@ output texts in the German language if possible::
--humanize --language=german


Forecasting
===========

Specific events
---------------
Forecast of "beginning of flowering" events at station "Berlin-Dahlem".
Use all species of the "primary group": "hazel", "snowdrop", "goat willow",
"dandelion", "cherry", "apple", "winter oilseed rape", "black locust" and "common heather".
Sort by date, ascending.

phenodata forecast \
--source=dwd --dataset=annual --partition=recent \
--filename=Hasel,Schneegloeckchen,Sal-Weide,Loewenzahn,Suesskirsche,Apfel,Winterraps,Robinie,Winter-Linde,Heidekraut \
--station-id=12132 --phase-id=5 \
--humanize \
--sort=Datum

Event sequence for each species
-------------------------------
Forecast of all events at station "Berlin-Dahlem".
Use all species of the "primary group" (dito).
Sort by species and date, ascending.

phenodata forecast \
--source=dwd --dataset=annual --partition=recent \
--filename=Hasel,Schneegloeckchen,Sal-Weide,Loewenzahn,Suesskirsche,Apfel,Winterraps,Robinie,Winter-Linde,Heidekraut \
--station-id=12132 \
--humanize --lang=german \
--sort=Spezies,Datum


*************************
Humanized search examples
*************************
Expand Down
11 changes: 9 additions & 2 deletions phenodata/command.py
Expand Up @@ -31,8 +31,8 @@ def run():
phenodata list-quality-bytes --source=dwd [--format=csv]
phenodata list-filenames --source=dwd --dataset=immediate --partition=recent [--filename=Hasel,Schneegloeckchen] [--year=2017]
phenodata list-urls --source=dwd --dataset=immediate --partition=recent [--filename=Hasel,Schneegloeckchen] [--year=2017]
phenodata (observations|forecast) --source=dwd --dataset=immediate --partition=recent [--filename=Hasel,Schneegloeckchen] [--station-id=164,717] [--species-id=113,127] [--phase-id=5] [--quality-level=10] [--quality-byte=1,2,3] [--year=2017] [--humanize] [--language=german] [--format=csv]
phenodata (observations|forecast) --source=dwd --dataset=immediate --partition=recent [--filename=Hasel,Schneegloeckchen] [--station=berlin,brandenburg] [--species=hazel,snowdrop] [--phase=flowering] [--year=2017] [--humanize] [--language=german] [--format=csv]
phenodata (observations|forecast) --source=dwd --dataset=immediate --partition=recent [--filename=Hasel,Schneegloeckchen] [--station-id=164,717] [--species-id=113,127] [--phase-id=5] [--quality-level=10] [--quality-byte=1,2,3] [--year=2017] [--humanize] [--language=german] [--sort=Datum] [--format=csv]
phenodata (observations|forecast) --source=dwd --dataset=immediate --partition=recent [--filename=Hasel,Schneegloeckchen] [--station=berlin,brandenburg] [--species=hazel,snowdrop] [--phase=flowering] [--year=2017] [--humanize] [--language=german] [--sort=Datum] [--format=csv]
phenodata --version
phenodata (-h | --help)
Expand All @@ -58,6 +58,7 @@ def run():
With "tabular", it is also possible to specify the table format,
see https://bitbucket.org/astanin/python-tabulate. e.g. "tabular:presto".
[default: tabular:psql]
--sort=<sort> Sort by given column names (comma-separated list)
--humanize Resolve ID-based columns to real names with "observations" and "forecast" output.
--language=<language> Use labels in designated language when using ``--humanize`` [default: english].
--limit=<limit> Limit output of "nearest-stations" to designated number of entries.
Expand Down Expand Up @@ -94,6 +95,9 @@ def run():
'location',
'species',
'phase',

# Sorting parameters
'sort',
])

# Command line argument debugging
Expand Down Expand Up @@ -159,6 +163,9 @@ def run():
if options['forecast'] and options['humanize']:
showindex = False

# Sort columns
if options['sort']:
data.sort_values(options['sort'], inplace=True)

output = None
if output_format.startswith('tabular'):
Expand Down

0 comments on commit 7c65680

Please sign in to comment.