<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="/assets/xslt/atom.xslt" ?>
<?xml-stylesheet type="text/css" href="/assets/css/atom.css" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>https://retostauffer.org/</id>
	<title>retostauffer.org</title>
	<updated>2025-08-26T17:18:16+02:00</updated>

	<subtitle>»retostauffer.org« is a private webpage to share some ideas and code snippets.</subtitle>

	
		
		<author>
			
				<name>reto</name>
			
			
			
		</author>
	

	<link href="https://retostauffer.org/atom.xml" rel="self" type="application/rss+xml" />
	<link href="https://retostauffer.org/" rel="alternate" type="text/html" />

	<generator uri="http://jekyllrb.com" version="4.3.4">Jekyll</generator>

	
		<entry>
			<id>https://retostauffer.org/news/exams/</id>
			<title>R/exams upgrades, features, and improvements</title>
			<link href="https://retostauffer.org/news/exams/" rel="alternate" type="text/html" title="R/exams upgrades, features, and improvements" />
			<updated>2025-05-02T00:00:00+02:00</updated>

			
				
				<author>
					
						<name>reto, zeileis</name>
					
					
					
				</author>
			
			<summary>In early May 2025, we released new versions of both the R/exams package as well as the exams2forms extension. These updates include bug fixes, various refinements, and several new features.</summary>
			<content type="html" xml:base="https://retostauffer.org/news/exams/">&lt;p&gt;Over the past weeks and months we have been updating both the
&lt;a href=&quot;https://cran.r-project.org/package=exams&quot;&gt;R/exams&lt;/a&gt; package as well as it’s
newest extension
&lt;a href=&quot;https://cran.r-project.org/package=exams2forms&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exams2forms&lt;/code&gt;&lt;/a&gt; to resolve
known (and new) issues as well as extend the functionality of both packages. I
would like to thank everyone involved in the latest additions and improvements!&lt;/p&gt;

&lt;p&gt;I, myself, was mainly involved in &lt;em&gt;(i)&lt;/em&gt; extending and refining the stresstest
functionalilty to automatically stress-testing R/exams exercise questions, as
well as &lt;em&gt;(ii)&lt;/em&gt; refining and extending the functionality of the &lt;em&gt;R&lt;/em&gt;-package
&lt;a href=&quot;https://cran.r-project.org/package=exams2forms&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exams2forms&lt;/code&gt;&lt;/a&gt; which now
provides additional features for our users developing and testing R/exams
exercise questions.&lt;/p&gt;

&lt;h1 id=&quot;rexams&quot;&gt;R/exams&lt;/h1&gt;

&lt;h2 id=&quot;stresstesting-exercises&quot;&gt;Stresstesting exercises&lt;/h2&gt;

&lt;p&gt;For quite some time, the &lt;a href=&quot;https://cran.r-project.org/package=exams&quot;&gt;R/exams&lt;/a&gt;
package provides automated stress-tests for (one or multiple) exercises
using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stresstest_exercise()&lt;/code&gt; function (see e.g., our tutorial on
&lt;a href=&quot;https://www.r-exams.org/tutorials/stresstest/&quot;&gt;Stress Testing Dynamic R/exams Exercises&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Whilst always working perfectly fine, one inconvenience was that the function
may ‘stall’ if an exercise was taking an unexpectedly long time to be generated
(or ended up in an infinite loop in the worst case).&lt;/p&gt;

&lt;p&gt;The new release of &lt;a href=&quot;https://cran.r-project.org/package=exams&quot;&gt;R/exams&lt;/a&gt; now
allows to set a timeout. This useful if one wants to identify
exercises which take “too long” to be rendered, or exercises which may end up
in infinite loops. It becomes especially useful if one want’s to check or test
extensive libraries of exercises (hundreds or thousands) and stress-test them
extensively (generate them hundreds or thousand times).
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stresstest_exercise()&lt;/code&gt; now allows to set timeouts which will result in an error
if violated. In addition, this is reported back to the user (see below).&lt;/p&gt;

&lt;p&gt;Besides a timeout option, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stresstest_exercise()&lt;/code&gt; now reports all warnings and
errors captured during execution. This feature is available no matter if you
only test one exercise (you must set &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stop_on_error = FALSE&lt;/code&gt;) or stacks of
exercises. This allows to stress-test bulks of exercises and not only get
reported where errors occured and how often, but also where warnings have
been raised and how often, even if–a the end–the questions was successfully
rendered.&lt;/p&gt;

&lt;h2 id=&quot;num_to_schoice&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;num_to_schoice()&lt;/code&gt;&lt;/h2&gt;

&lt;p&gt;The extension of the stresstest-functionality above was somewhat interlocked
with the function &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;num_to_schoice()&lt;/code&gt; which allows to generate single-choice
questions from a numeric solution. If the data generation of an exercise is
badly written, it can cause &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;num_to_schoice()&lt;/code&gt; to search for a possible (valid)
return forever. Besides the new timeout-feature of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stresstest_exercise()&lt;/code&gt;, 
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;num_to_schoice()&lt;/code&gt; has also been updated, allowing to specify how often the
function is allowed to try to find a valid solution (return) via it’s new
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;maxit&lt;/code&gt; argument which can also be set global (via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getOption&lt;/code&gt;). See
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;?num_to_schoice&lt;/code&gt; for more details.&lt;/p&gt;

&lt;h1 id=&quot;exams2forms&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exams2forms&lt;/code&gt;&lt;/h1&gt;

&lt;h2 id=&quot;developmenttesting-features&quot;&gt;Development/testing features&lt;/h2&gt;

&lt;p&gt;Besides &lt;a href=&quot;https://cran.r-project.org/package=exams2forms&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exams2forms&lt;/code&gt;&lt;/a&gt;
providing great functionality to use for stand-allone versions of R/exams, its
functionalty also helps those writing new exercises or testing existing ones.
With the new release, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exams2forms()&lt;/code&gt; (called by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exams2webquiz()&lt;/code&gt;) got some new
features allowing to &lt;em&gt;(i)&lt;/em&gt; display the name of the exercise (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;show_filename&lt;/code&gt;),
show &lt;em&gt;(ii)&lt;/em&gt; the required tolerance for correct answers of numeric questions
(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;show_tolerance&lt;/code&gt;), as well as &lt;em&gt;(iii)&lt;/em&gt; features to be used by developers/testers
to quickly check if everything is set up correctly (see argument &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;auto&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Check out &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;?exams2forms&lt;/code&gt; for more details (all available via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exams2webquiz()&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;############################################################################&lt;/p&gt;

&lt;p&gt;Over the past weeks and months, we have been updating both the
&lt;a href=&quot;https://cran.r-project.org/package=exams&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;R/exams&lt;/code&gt;&lt;/a&gt; package and its newest
extension, &lt;a href=&quot;https://cran.r-project.org/package=exams2forms&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exams2forms&lt;/code&gt;&lt;/a&gt;, to
resolve known (and new) issues and to expand the functionality of both
packages. I’d like to thank everyone involved in the latest additions and
improvements!&lt;/p&gt;

&lt;p&gt;I was primarily involved in:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Extending and refining the &lt;strong&gt;stresstest&lt;/strong&gt; functionality to automatically&lt;br /&gt;
stress-test R/exams exercise questions, and&lt;/li&gt;
  &lt;li&gt;Improving and extending the functionality of the R package
&lt;a href=&quot;https://cran.r-project.org/package=exams2forms&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exams2forms&lt;/code&gt;&lt;/a&gt;,
which now offers additional features for users developing and testing R/exams exercises.&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;rexams-1&quot;&gt;R/exams&lt;/h1&gt;

&lt;h2 id=&quot;stress-testing-exercises&quot;&gt;Stress-testing Exercises&lt;/h2&gt;

&lt;p&gt;The &lt;a href=&quot;https://cran.r-project.org/package=exams&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;R/exams&lt;/code&gt;&lt;/a&gt; package has long
supported automated stress-testing of one or multiple exercises via the 
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stresstest_exercise()&lt;/code&gt; function (see the tutorial on&lt;br /&gt;
&lt;a href=&quot;https://www.r-exams.org/tutorials/stresstest/&quot;&gt;Stress Testing Dynamic R/exams Exercises&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;While this functionality has worked reliably and as originally intended, it had
one limitation: if an exercise took too long to generate–or entered an
infinite loop–the function possibly stalled.&lt;/p&gt;

&lt;p&gt;The latest release introduces a &lt;strong&gt;timeout option&lt;/strong&gt;. This is especially helpful
when testing large libraries of exercises (hundreds or thousands), allowing you
to flag exercises that take too long to render or never complete. If the
timeout is exceeded, an error is raised and reported to the user.&lt;/p&gt;

&lt;p&gt;In addition, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stresstest_exercise()&lt;/code&gt; now captures and reports all &lt;strong&gt;warnings&lt;/strong&gt;
and &lt;strong&gt;errors&lt;/strong&gt; during execution. This applies whether you’re testing a single
exercise (set &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stop_on_error = FALSE&lt;/code&gt;) or a large batch. You’ll get detailed
feedback on where and how often issues occurred—even if an exercise was
ultimately rendered successfully.&lt;/p&gt;

&lt;h2 id=&quot;num_to_schoice-1&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;num_to_schoice()&lt;/code&gt;&lt;/h2&gt;

&lt;p&gt;The improvements on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stresstest_exercise()&lt;/code&gt; were closely related to updates in
the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;num_to_schoice()&lt;/code&gt; function, which creates single-choice questions from
numeric solutions. Poorly written generation code could previously cause
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;num_to_schoice()&lt;/code&gt; to loop indefinitely in search of a valid return.&lt;/p&gt;

&lt;p&gt;Alongside the timeout in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stresstest_exercise()&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;num_to_schoice()&lt;/code&gt; now
accepts a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;maxit&lt;/code&gt; argument, specifying the maximum number of attempts before
giving up. This can also be set globally using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setOpttion()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;See &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;?num_to_schoice&lt;/code&gt; for full details.&lt;/p&gt;

&lt;h1 id=&quot;exams2forms-1&quot;&gt;exams2forms&lt;/h1&gt;

&lt;h2 id=&quot;development-and-testing-features&quot;&gt;Development and Testing Features&lt;/h2&gt;

&lt;p&gt;In addition to supporting stand-alone versions of R/exams exercises,
&lt;a href=&quot;https://cran.r-project.org/package=exams2forms&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exams2forms&lt;/code&gt;&lt;/a&gt; now includes
additional features that are especially helpful when &lt;strong&gt;developing or testing exercises&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The updated &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exams2forms()&lt;/code&gt; function (typically called via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exams2webquiz()&lt;/code&gt;)
got the following new options:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;show_filename&lt;/code&gt;: Displays the name of the exercise file.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;show_tolerance&lt;/code&gt;: Shows the tolerance for numeric answers.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;auto&lt;/code&gt;: Enables developer/tester-specific features for quick verification
that everything is correctly set up.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check out &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;?exams2forms&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;?exams2webquiz&lt;/code&gt; for more details.&lt;/p&gt;

</content>

			
				<category term="news" />
			
			
				<category term="exams" />
			
				<category term="exams2forms" />
			
				<category term="R" />
			

			<published>2025-05-02T00:00:00+02:00</published>
		</entry>
	
		<entry>
			<id>https://retostauffer.org/news/exams2forms/</id>
			<title>exams2forms: Embedding &apos;exams&apos; exercises in HTML documents</title>
			<link href="https://retostauffer.org/news/exams2forms/" rel="alternate" type="text/html" title="exams2forms: Embedding &apos;exams&apos; exercises in HTML documents" />
			<updated>2024-11-11T00:00:00+01:00</updated>

			
				
				<author>
					
						<name>reto, zeileis</name>
					
					
					
				</author>
			
			<summary>In November 2024, we released the new R package exams2forms, adding new features and building blocks for embedding (randomized) exercises written for the R package exams (aka. R/exams) as interactive elements in documents written with rmarkdown or quarto.</summary>
			<content type="html" xml:base="https://retostauffer.org/news/exams2forms/">&lt;p&gt;The goal is to enable users to easily re-use
&lt;a href=&quot;https://www.r-exams.org/intro/dynamic/&quot;&gt;dynamic exercises&lt;/a&gt;
written in one of R/exams’ formats in HTML documents, such as stand-alone
HTML files, online books, or websites.&lt;/p&gt;

&lt;p&gt;This allows to provide additional self-assessment resources without the need for
a learning management systems (e.g., OpenOlat, Moodle, Canvas, …) and
supports all R/exams exercise types: single-choice, multiple-choice,
numeric and text questions, as well as cloze questions combining one
or all of the previously mentioned types.&lt;/p&gt;

&lt;p&gt;Exercises written for &lt;a href=&quot;https://cran.r-project.org/package=exams2forms&quot;&gt;&lt;em&gt;exams2forms&lt;/em&gt;&lt;/a&gt;
can be easily used in (summative) assessments and vice versa, as they share the
same format.
&lt;a href=&quot;https://cran.r-project.org/package=exams2forms&quot;&gt;&lt;em&gt;exams2forms&lt;/em&gt;&lt;/a&gt; is a valuable
addition to the features and capabilities of 
the &lt;a href=&quot;https://www.r-exams.org/&quot;&gt;&lt;em&gt;exams&lt;/em&gt;&lt;/a&gt; package, offering even more
flexibility.&lt;/p&gt;

&lt;p&gt;Interested? Our &lt;a href=&quot;https://www.r-exams.org/tutorials/exams2forms/&quot;&gt;online tutorial&lt;/a&gt;
provides interactive examples and templates to get you started today!&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;R package: &lt;a href=&quot;https://cran.r-project.org/package=exams2forms&quot;&gt;https://cran.r-project.org/package=exams2forms&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Tutorial: &lt;a href=&quot;https://www.r-exams.org/tutorials/exams2forms/&quot;&gt;https://www.r-exams.org/tutorials/exams2forms/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</content>

			
				<category term="news" />
			
			
				<category term="exams" />
			
				<category term="exams2forms" />
			
				<category term="R" />
			

			<published>2024-11-11T00:00:00+01:00</published>
		</entry>
	
		<entry>
			<id>https://retostauffer.org/news/python-colorspace/</id>
			<title>colorspace: A Python toolbox for colors and palettes</title>
			<link href="https://retostauffer.org/news/python-colorspace/" rel="alternate" type="text/html" title="colorspace: A Python toolbox for colors and palettes" />
			<updated>2024-07-30T00:00:00+02:00</updated>

			
				
				<author>
					
						<name>zeileis</name>
					
					
					
				</author>
			
			<summary>Python package &apos;colorspace&apos; with tools for manipulating and assessing colors and palettes is now available from PyPI, accompanied by a documentation web page and an arXiv paper.</summary>
			<content type="html" xml:base="https://retostauffer.org/news/python-colorspace/">&lt;p&gt;&lt;img src=&quot;https://retostauffer.org/images/posts/2024-07-30-python_colorspace/logo-wide.png&quot; alt=&quot;Python colorspace logo&quot; width=&quot;400px&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;citation&quot;&gt;Citation&lt;/h2&gt;

&lt;p&gt;Reto Stauffer, Achim Zeileis (2024). “colorspace: A Python Toolbox for Manipulating and Assessing Colors and Palettes.” &lt;em&gt;arXiv.org E-Print Archive&lt;/em&gt; arXiv:2407.19921 [cs.GR]. &lt;a href=&quot;https://doi.org/10.48550/arXiv.2407.19921&quot;&gt;doi:10.48550/arXiv.2407.19921&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;abstract&quot;&gt;Abstract&lt;/h2&gt;

&lt;p&gt;The Python &lt;em&gt;colorspace&lt;/em&gt; package provides a toolbox for mapping between different color spaces which can then be used to generate a wide range of perceptually-based color palettes for qualitative or quantitative (sequential or diverging) information. These palettes (as well as any other sets of colors) can be visualized, assessed, and manipulated in various ways, e.g., by color swatches, emulating the effects of color vision deficiencies, or depicting the perceptual properties. Finally, the color palettes generated by the package can be easily integrated into standard visualization workflows in Python, e.g., using &lt;em&gt;matplotlib&lt;/em&gt;, &lt;em&gt;seaborn&lt;/em&gt;, or &lt;em&gt;plotly&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://arxiv.org/pdf/2407.19921&quot;&gt;Read full paper ›&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;software&quot;&gt;Software&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Package (PyPI): &lt;a href=&quot;https://pypi.org/project/colorspace/&quot;&gt;https://pypi.org/project/colorspace/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Documentation: &lt;a href=&quot;https://retostauffer.github.io/python-colorspace/&quot;&gt;https://retostauffer.github.io/python-colorspace/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Interactive apps: &lt;a href=&quot;https://hclwizard.org/&quot;&gt;https://hclwizard.org/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Repository (GitHub): &lt;a href=&quot;https://github.com/retostauffer/python-colorspace/&quot;&gt;https://github.com/retostauffer/python-colorspace/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;motivation&quot;&gt;Motivation&lt;/h2&gt;

&lt;p&gt;Color is an integral element of visualizations and graphics and is essential for communicating (scientific) information. However, colors need to be chosen carefully so that they support the information displayed for all viewers (see e.g., Tufte 1990; Ware 2004; Wilke 2019). Therefore, suitable color palettes have been proposed in the literature (e.g., Brewer 1999; Ihaka 2003; Crameri, Shephard, and Heron 2020) and many software packages transitioned to better color defaults over the last decade. A prominent example from the Python community is &lt;em&gt;matplotlib&lt;/em&gt; 2.0 (Hunter, Dale, Firing, Droettboom, and the Matplotlib Development Team 2017) which replaced the classic “jet” palette (a variation of the infamous “rainbow”) by the perceptually-based “viridis” palette. Hence a wide range of useful palettes for different purposes is provided in a number of Python packages today, including &lt;em&gt;cmcramery&lt;/em&gt; (Rollo 2024), &lt;em&gt;colormap&lt;/em&gt; (Cokelaer 2024), &lt;em&gt;colormaps&lt;/em&gt; (Patel 2024), &lt;em&gt;matplotlib&lt;/em&gt; (Hunter 2007), &lt;em&gt;palettable&lt;/em&gt; (Davis 2023), or &lt;em&gt;seaborn&lt;/em&gt; (Waskom 2021).&lt;/p&gt;

&lt;p&gt;However, in most graphics packages colors are provided as a fixed set. While this makes it easy to use them in different applications, it is usually not easy to modify the perceptual properties or to set up new palettes following the same principles. The &lt;em&gt;colorspace&lt;/em&gt; package addresses this by supporting color descriptions using different color spaces (hence the package name), including some that are based on human color perception. One notable example is the Hue-Chroma-Luminance (HCL) model which represents colors by coordinates on three perceptually-based axes: Hue (type of color), chroma (colorfulness), and luminance (brightness). Selecting colors along paths along these axes allows for intuitive construction of palettes that closely match many of the palettes provided in the packages listed above.&lt;/p&gt;

&lt;p&gt;In addition to functions and interactive apps for HCL-based colors, the &lt;em&gt;colorspace&lt;/em&gt; package also offers functions and classes for handling, transforming, and visualizing color palettes (from any source). In particular, this includes the simulation of color vision deficiencies (Machado Oliviera, and Fernandes 2009) but also contrast ratios, desaturation, lightening/darkening, etc.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;colorspace&lt;/em&gt; Python package was inspired by the eponymous R package (Zeileis, Fisher, Hornik, Ihaka, McWhite, Murrell, Stauffer, and Wilke 2020). It comes with extensive documentation at &lt;a href=&quot;https://retostauffer.github.io/python-colorspace/&quot;&gt;https://retostauffer.github.io/python-colorspace/&lt;/a&gt;, including many practical examples. Selected highlights are presented in the following.&lt;/p&gt;

&lt;h2 id=&quot;key-functionality&quot;&gt;Key functionality&lt;/h2&gt;

&lt;h3 id=&quot;hcl-based-color-palettes&quot;&gt;HCL-based color palettes&lt;/h3&gt;

&lt;p&gt;The key functions and classes for constructing color palettes using hue-chroma-luminance paths (and then mapping these to hex codes) are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;qualitative_hcl&lt;/code&gt;: For qualitative or unordered categorical information, where every color should receive a similar perceptual weight.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sequential_hcl&lt;/code&gt;: For ordered/numeric information from high to low (or vice versa).&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;diverging_hcl&lt;/code&gt;: For ordered/numeric information around a central neutral value, where colors diverge from neutral to two extremes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These functions provide a range of named palettes inspired by well-established packages but actually implemented using HCL paths. Additionally, the HCL parameters can be modified or new palettes can be created from scratch.&lt;/p&gt;

&lt;p&gt;As an example, the figure below depicts color swatches for four viridis variations. The first &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pal1&lt;/code&gt; sets up the palette from its name. It is identical to the second &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pal2&lt;/code&gt; which employes the HCL specification directly: The hue ranges from purple (300) to yellow (75), colorfulness (chroma) increases from 40 to 95, and luminance (brightness) from dark (15) to light (90). The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;power&lt;/code&gt; parameter chooses a linear change in chroma and a slightly nonlinear path for luminance.&lt;/p&gt;

&lt;p&gt;In &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pal3&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pal4&lt;/code&gt; the most HCL properties are kept the same but some are modified: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pal3&lt;/code&gt; uses a triangular chroma path from 40 via 90 to 20, yielding muted colors at the end of the palette. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pal4&lt;/code&gt; just changes the starting hue for the palette to green (200) instead of purple. All four palettes are visualized by the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;swatchplot&lt;/code&gt; function from the package.&lt;/p&gt;

&lt;p&gt;The objects returned by the palette functions provide a series of methods, e.g., &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pal1.settings&lt;/code&gt; for displaying the HCL parameters, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pal1(3)&lt;/code&gt; for obtaining a number of hex colors, or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pal1.cmap()&lt;/code&gt; for setting up a &lt;em&gt;matplotlib&lt;/em&gt; color map, among others.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-{python}&quot;&gt;from colorspace import palette, sequential_hcl, swatchplot

pal1 = sequential_hcl(palette = &quot;viridis&quot;)
pal2 = sequential_hcl(h = [300, 75], c = [40, 95], l = [15, 90],
                      power = [1., 1.1])
pal3 = sequential_hcl(palette = &quot;viridis&quot;, cmax = 90,  c2 = 20)
pal4 = sequential_hcl(palette = &quot;viridis&quot;, h1 = 200)

swatchplot({&quot;Viridis (and altered versions of it)&quot;: [
               palette(pal1(7), &quot;By name&quot;), 
               palette(pal2(7), &quot;By hand&quot;),
               palette(pal3(7), &quot;With triangular chroma&quot;),
               palette(pal4(7), &quot;With smaller hue range&quot;)
           ]}, figsize = (8, 1.75));
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src=&quot;https://retostauffer.org/images/posts/2024-07-30-python_colorspace/fig-chosing-palettes.png&quot; alt=&quot;Swatches of four HCL-based sequential palettes: `pal1` is the predefined HCL-based viridis palette, `pal2` is identical to `pal2` but created &amp;quot;by hand&amp;quot; and `pal3` and `pal4` are modified versions with a triangular chroma paths and reduced hue range, respectively.&quot; /&gt;&lt;/p&gt;

&lt;p&gt;An overview of the named HCL-based palettes in &lt;em&gt;colorspace&lt;/em&gt; is depicted below.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-{python}&quot;&gt;from colorspace import hcl_palettes
hcl_palettes(plot = True, figsize = (20, 15))
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src=&quot;https://retostauffer.org/images/posts/2024-07-30-python_colorspace/fig-hcl-palettes.png&quot; alt=&quot;Overview of the predefined (fully customizable) HCL color palettes.&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;palette-visualization-and-assessment&quot;&gt;Palette visualization and assessment&lt;/h3&gt;

&lt;p&gt;To better understand the properties of palette &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pal4&lt;/code&gt;, defined above, the following figure shows its HCL spectrum (left) and the corresponding path through the HCL space (right).&lt;/p&gt;

&lt;p&gt;The spectrum in the first panel shows how the hue (right axis) changes from about 200 (green) to 75 (yellow), while chroma and luminance (left axis) increase from about 20 to 95. Note that the kink in the chroma curve for the greenish colors occurs because such dark greens cannot have higher chromas when represented through RGB-based hex codes. The same is visible in the second panel where the path moves along the outer edge of the HCL space.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-{python}&quot;&gt;pal4.specplot(figsize = (5, 5));
pal4.hclplot(n = 7, figsize = (5, 5));
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src=&quot;https://retostauffer.org/images/posts/2024-07-30-python_colorspace/fig-specplot-hclplot.png&quot; alt=&quot;Hue-chroma-luminance spectrum plot (left) and corresponding path in the chroma-luminance coordinate system (where hue changes with luminance) for the custom sequential palette `pal4`.&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;color-vision-deficiency&quot;&gt;Color vision deficiency&lt;/h3&gt;

&lt;p&gt;Another important assessment of a color palette is how well it works for viewers with color vision deficiencies. This is exemplified below by depicting a demo plot (heatmap) under “normal” vision (left), deuteranomaly (colloquially known as “red-green color blindness”, center), and desaturated (gray scale, right). The palette in the top row is the traditional fully-saturated RGB rainbow, deliberately selected here as a palette with poor perceptual properties. It is contrasted with a perceptually-based sequential blue-yellow HCL palette in the bottom row.&lt;/p&gt;

&lt;p&gt;The sequential HCL palette is monotonic in luminance so that it is easy to distinguish high-density and low-density regions under deuteranomaly and desaturation. However, the rainbow is non-monotonic in luminance and parts of the red-green contrasts collapse under deuteranomaly, making it much harder to interpret correctly.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-{python}&quot;&gt;from colorspace import rainbow, sequential_hcl
col1 = rainbow(end = 2/3, rev = True)(7)
col2 = sequential_hcl(&quot;Blue-Yellow&quot;, rev = True)(7)

from colorspace import demoplot, deutan, desaturate
import matplotlib.pyplot as plt

fig, ax = plt.subplots(2, 3, figsize = (9, 4))
demoplot(col1, &quot;Heatmap&quot;, ax = ax[0,0], ylabel = &quot;Rainbow&quot;, title = &quot;Original&quot;)
demoplot(col2, &quot;Heatmap&quot;, ax = ax[1,0], ylabel = &quot;HCL (Blue-Yellow)&quot;)
demoplot(deutan(col1), &quot;Heatmap&quot;, ax = ax[0,1], title = &quot;Deuteranope&quot;)
demoplot(deutan(col2), &quot;Heatmap&quot;, ax = ax[1,1])
demoplot(desaturate(col1), &quot;Heatmap&quot;, ax = ax[0,2], title = &quot;Desaturated&quot;)
demoplot(desaturate(col2), &quot;Heatmap&quot;, ax = ax[1,2])
plt.show()
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src=&quot;https://retostauffer.org/images/posts/2024-07-30-python_colorspace/fig-cvd.png&quot; alt=&quot;Example of color vision deficiency emulation and color manipulation using a heatmap. Top/bottom: RGB rainbow based palette and HCL based sequential palette. Left to right: Original colors, deuteranope color vision, and desaturated representation.&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;integration-with-python-graphics-packages&quot;&gt;Integration with Python graphics packages&lt;/h3&gt;

&lt;p&gt;To illustrate that &lt;em&gt;colorspace&lt;/em&gt; can be easily combined with different graphics workflows in Python, the code below shows a heatmap (two-dimensional histogram) from &lt;em&gt;matplotlib&lt;/em&gt; and multi-group density from &lt;em&gt;seaborn&lt;/em&gt;. The code below employs an example data set from the package (using &lt;em&gt;pandas&lt;/em&gt;) with daily maximum and minimum temperature. For &lt;em&gt;matplotlib&lt;/em&gt; the colormap (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.cmap()&lt;/code&gt;; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LinearSegmentedColormap&lt;/code&gt;) is extracted from the adapted viridis palette &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pal3&lt;/code&gt; defined above. For &lt;em&gt;seaborn&lt;/em&gt; the hex codes from a custom qualitative palette are extracted via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.colors(4)&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-{python}&quot;&gt;from colorspace import dataset, qualitative_hcl
import matplotlib.pyplot as plt
import seaborn as sns

df = dataset(&quot;HarzTraffic&quot;)

fig = plt.hist2d(df.tempmin, df.tempmax, bins = 20,
                 cmap = pal3.cmap().reversed())
plt.title(&quot;Joint density daily min/max temperature&quot;)
plt.xlabel(&quot;minimum temperature [deg C]&quot;)
plt.ylabel(&quot;maximum temperature [deg C]&quot;)
plt.show()

pal = qualitative_hcl(&quot;Dark 3&quot;, h1 = -180, h2 = 100)
g = sns.displot(data = df, x = &quot;tempmax&quot;, hue = &quot;season&quot;, fill = &quot;season&quot;,   
                kind = &quot;kde&quot;, rug = True, height = 4, aspect = 1,
                palette = pal.colors(4))
g.set_axis_labels(&quot;temperature [deg C]&quot;)              
g.set(title = &quot;Distribution of daily maximum temperature given season&quot;)
plt.show()
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src=&quot;https://retostauffer.org/images/posts/2024-07-30-python_colorspace/fig-plotting.png&quot; alt=&quot;Example of a `matplotlib` heatmap and a `seaborn` density using custom HCL-based colors.&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;dependencies-and-availability&quot;&gt;Dependencies and availability&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;colorspace&lt;/em&gt; is available from PyPI at &lt;a href=&quot;https://pypi.org/project/colorspace&quot;&gt;https://pypi.org/project/colorspace&lt;/a&gt;. It is designed to be lightweight, requiring only &lt;em&gt;numpy&lt;/em&gt;  (Harris &lt;em&gt;et al.&lt;/em&gt; 2020) for the core functionality. Only a few features rely on &lt;em&gt;matplotlib&lt;/em&gt;, &lt;em&gt;imageio&lt;/em&gt; (Klein &lt;em&gt;et al.&lt;/em&gt; 2024), and &lt;em&gt;pandas&lt;/em&gt; (The Pandas Development Team 2024). More information and an interactive interface can be found on &lt;a href=&quot;https://hclwizard.org/&quot;&gt;https://hclwizard.org/&lt;/a&gt;. Package development is hosted on GitHub at &lt;a href=&quot;https://github.com/retostauffer/python-colorspace&quot;&gt;https://github.com/retostauffer/python-colorspace&lt;/a&gt;. Bug reports, code contributions, and feature requests are warmly welcome.&lt;/p&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Brewer CA (1999). “Color Use Guidelines for Data Representation.” In Proceedings of the Section on Statistical Graphics, American Statistical Association, pp. 55–60. Alexandria, VA.&lt;/li&gt;
  &lt;li&gt;Cokelaer T (2024). Colormap. Version 1.1.0, Python Package Index (PyPI), URL &lt;a href=&quot;https://pypi.org/project/colormap/&quot;&gt;https://pypi.org/project/colormap/&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Crameri F, Shephard GE, Heron PJ (2020). “The Misuse of Colour in Science Communication.” Nature Communications, 11(5444), 1–10. &lt;a href=&quot;https://doi.org/10.1038/s41467-020-19160-7&quot;&gt;doi:10.1038/s41467-020-19160-7&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Davis M (2023). palettable: Color Palettes for Python. Version 3.3.3, Python Package Index (PyPI), URL &lt;a href=&quot;https://pypi.org/project/palettable/&quot;&gt;https://pypi.org/project/palettable/&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Harris CR, Millman KJ, van der Walt SJ, Gommers R, Virtanen P, Cournapeau D, Wieser E, Taylor J, Berg S, Smith NJ, Kern R, Picus M, Hoyer S, van Kerkwijk MH, Brett M, Haldane A, del Río JF, Wiebe M, Peterson P, Gérard-Marchant P, Sheppard K, Reddy T, Weckesser W, Abbasi H, Gohlke C, Oliphant TE (2020). “Array Programming with NumPy.” Nature, 585(7825), 357–362. &lt;a href=&quot;https://doi.org/10.1038/s41586-020-2649-2&quot;&gt;doi:10.1038/s41586-020-2649-2&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Hunter JD (2007). “Matplotlib: A 2D Graphics Environment.” Computing in Science &amp;amp; Engineering, 9(3), 90–95. &lt;a href=&quot;https://doi.org/10.1109/mcse.2007.55&quot;&gt;doi:10.1109/mcse.2007.55&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Hunter JD, Dale D, Firing E, Droettboom M, the Matplotlib Development Team (2017). “What’s New in Matplotlib 2.0 (Jan 17, 2017), Changes to the Default Style.” Accessed 2024-07-22, URL &lt;a href=&quot;https://matplotlib.org/stable/users/prev_whats_new/dflt_style_changes.html&quot;&gt;https://matplotlib.org/stable/users/prev_whats_new/dflt_style_changes.html&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Ihaka R (2003). “Colour for Presentation Graphics.” In K Hornik, F Leisch, A Zeileis (eds.), Proceedings of the 3rd International Workshop on Distributed Statistical Computing, Vienna, Austria. ISSN 1609-395X, URL &lt;a href=&quot;https://www.R-project.org/conferences/DSC-2003/Proceedings/Ihaka.pdf&quot;&gt;https://www.R-project.org/conferences/DSC-2003/Proceedings/Ihaka.pdf&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Klein A, Wallkötter S, Silvester S, Rynes A, actions-user, Müller P, Nunez-Iglesias J, Harfouche M, Schrangl L, Dennis, Lee A, Pandede, McCormick M, OrganicIrradiation, Rai A, Ladegaard A, van Kemenade H, Smith TD, Vaillant G, jackwalker64, Nises J, Komarčevič M, rreilink, Barnes C, Zulko, Hsieh PC, Rosenstein N, Górny M, scivision, Singleton J (2024). Imageio/Imageio: V2.34.2. &lt;a href=&quot;https://doi.org/10.5281/zenodo.12514964&quot;&gt;doi:10.5281/zenodo.12514964&lt;/a&gt;. Version 2.34.2, Zenodo.&lt;/li&gt;
  &lt;li&gt;Machado GM, Oliviera MM, Fernandes LAF (2009). “A Physiologically-Based Model for Simulation of Color Vision Deficiency.” IEEE Transactions on Visualization and Computer Graphics, 15(6), 1291–1298. &lt;a href=&quot;https://doi.org/10.1109/tvcg.2009.113&quot;&gt;doi:10.1109/tvcg.2009.113&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Patel P (2024). Colormaps. Version 0.4.2, Python Package Index (PyPI), URL &lt;a href=&quot;https://pypi.org/project/colormaps/&quot;&gt;https://pypi.org/project/colormaps/&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Rollo C (2024). cmcrameri: Python Wrapper around Fabio Crameri’s Perceptually Uniform Colormaps. Version 1.9, Python Package Index (PyPI), URL &lt;a href=&quot;https://pypi.org/project/cmcrameri/&quot;&gt;https://pypi.org/project/cmcrameri/&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;The Pandas Development Team (2024). pandas-Dev/Pandas: Pandas. &lt;a href=&quot;https://doi.org/10.5281/zenodo.10957263&quot;&gt;doi:10.5281/zenodo.10957263&lt;/a&gt;. Version 2.2.2, Zenodo.&lt;/li&gt;
  &lt;li&gt;Tufte E (1990). Envisioning Information. Graphics Press, Cheshire.&lt;/li&gt;
  &lt;li&gt;Ware C (2004). “Color.” In Information Visualization: Perception for Design, chapter 4, pp. 103–149. Morgan Kaufmann Publishers Inc.&lt;/li&gt;
  &lt;li&gt;Waskom ML (2021). “seaborn: Statistical Data Visualization.” Journal of Open Source Software, 6(60), 3021. &lt;a href=&quot;https://doi.org/10.21105/joss.03021&quot;&gt;doi:10.21105/joss.03021&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Wilke CO (2019). Fundamentals of Data Visualization. O’Reilly Media. ISBN 1492031089. URL &lt;a href=&quot;https://clauswilke.com/dataviz/color-basics.html&quot;&gt;https://clauswilke.com/dataviz/color-basics.html&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Zeileis A, Fisher JC, Hornik K, Ihaka R, McWhite CD, Murrell P, Stauffer R, Wilke CO (2020). “colorspace: A Toolbox for Manipulating and Assessing Colors and Palettes.” Journal of Statistical Software, 96(1), 1–49. &lt;a href=&quot;https://doi.org/10.18637/jss.v096.i01&quot;&gt;doi:10.18637/jss.v096.i01&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
</content>

			
				<category term="news" />
			
			
				<category term="color" />
			
				<category term="palettes" />
			
				<category term="Python" />
			

			<published>2024-07-30T00:00:00+02:00</published>
		</entry>
	
		<entry>
			<id>https://retostauffer.org/news/gsdata/</id>
			<title>gsdata: Interface to the GeoSphere Austria DataHub API (Data Access)</title>
			<link href="https://retostauffer.org/news/gsdata/" rel="alternate" type="text/html" title="gsdata: Interface to the GeoSphere Austria DataHub API (Data Access)" />
			<updated>2024-01-26T00:00:00+01:00</updated>

			
				
				<author>
					
						<name>reto</name>
					
					
					
				</author>
			
			<summary>Need weather or climate data for Austria? The R package &apos;gsdata&apos; provides easy access to the GeoSphere Austria API, allowing you to request and handle data from automated weather stations--and more.</summary>
			<content type="html" xml:base="https://retostauffer.org/news/gsdata/">&lt;div style=&quot;text-align: center; padding: 2em 0;&quot;&gt;
&lt;img src=&quot;https://retostauffer.org/images/posts/2024-01-26-gsdata/logo.svg&quot; alt=&quot;R gsdata logo&quot; width=&quot;250px&quot; /&gt;
&lt;/div&gt;

&lt;p&gt;In 2019, &lt;a href=&quot;https://www.geosphere.at&quot;&gt;GeoSphere Austria&lt;/a&gt; (formerly ZAMG) began offering public access to a
wide variety of weather, climate, and environmental data. Most of this data is
available under the &lt;a href=&quot;https://creativecommons.org/publicdomain/zero/1.0/&quot;&gt;Creative Commons Public Domain Dedication&lt;/a&gt;
(CC0) license, making it free to use for any application.&lt;/p&gt;

&lt;p&gt;The data can be retrieved through the
&lt;a href=&quot;https://data.hub.geosphere.at/&quot;&gt;GeoSphere Austria Data Hub&lt;/a&gt; API,
and the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gsdata&lt;/code&gt; R package provides a convenient interface to easily access
and process the data. Initially developed for personal use, this package may
require future updates or extensions.&lt;/p&gt;

&lt;p&gt;The example below demonstrates a basic use case. For more information and
additional examples, please refer to the &lt;a href=&quot;https://retostauffer.github.io/gsdata&quot;&gt;documentation.&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Documentation: &lt;a href=&quot;https://retostauffer.github.io/gsdata&quot;&gt;https://retostauffer.github.io/gsdata&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Repository: &lt;a href=&quot;https://github.com/retostauffer/gsdata&quot;&gt;https://github.com/retostauffer/gsdata&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Issues and bug reports: &lt;a href=&quot;https://github.com/retostauffer/gsdata/issues&quot;&gt;https://github.com/retostauffer/gsdata/issues&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;innsbruck-weather-data-example&quot;&gt;Innsbruck weather data (example)&lt;/h1&gt;

&lt;p&gt;The following call to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gs_stationdata()&lt;/code&gt; retrieves historical temperature,
dewpoint, and wind speed observations (synop; hourly data) for the first two
weeks of 2023 at Innsbruck Airport, station 11120.
When requesting data for a single station, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gs_stationdata()&lt;/code&gt; returns a time
series object. For multiple stations, the function will return a named list of
time series objects.&lt;/p&gt;

&lt;div class=&quot;language-r highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;library&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;gsdata&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;innsbruck&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gs_stationdata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;historical&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resource_id&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;synop-v1-1h&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;2023-01-01&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;         &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;2023-01-14&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;parameters&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;T&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Td&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ff&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;station_ids&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;11120&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The default plotting method allows to easily visualize the data:&lt;/p&gt;

&lt;div class=&quot;language-r highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Generic default plot&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;innsbruck&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://retostauffer.org/images/posts/2024-01-26-gsdata/plot_default.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-r highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Slightly modified plot&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;innsbruck&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
     &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;screen&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
     &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;col&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
     &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ylab&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;air temperature [C]\nwelt bulb temperature [C]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;mean wind speed [m/s]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://retostauffer.org/images/posts/2024-01-26-gsdata/plot_modified.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;available-data-sets&quot;&gt;Available data sets&lt;/h1&gt;

&lt;p&gt;As shown above, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gs_stationdata()&lt;/code&gt; requires a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mode&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;resource_id&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;station_ids&lt;/code&gt;, and (optional)
a list of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;parameters&lt;/code&gt;. The package provides a series of functions to list available
data sets as well as stations and parameters.&lt;/p&gt;

&lt;p&gt;As demonstrated above, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gs_stationdata()&lt;/code&gt; requires a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mode&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;resource_id&lt;/code&gt;,
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;station_ids&lt;/code&gt;, and optionally a list of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;parameters&lt;/code&gt; when called. The package also offers
several functions to list available datasets, stations, and parameters.&lt;/p&gt;

&lt;h2 id=&quot;data-sets&quot;&gt;Data sets&lt;/h2&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gs_datasets()&lt;/code&gt; returns a data.frame of available datasets from the GeoSphere Austria API.
By default, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gs_dataset()&lt;/code&gt; uses &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;type = &quot;stations&quot;&lt;/code&gt;, limiting the results to station-related datasets.&lt;/p&gt;

&lt;div class=&quot;language-r highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;ds&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gs_datasets&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;##      type       mode   resource_id data_format response_formats
## 1 station historical histalp-v1-1y     station      geojson|csv
## 2 station historical   klima-v1-1d     station      geojson|csv
## 3 station historical   klima-v1-1h     station      geojson|csv
##                                                                        url
## 1 https://dataset.api.hub.geosphere.at/v1/station/historical/histalp-v1-1y
## 2   https://dataset.api.hub.geosphere.at/v1/station/historical/klima-v1-1d
## 3   https://dataset.api.hub.geosphere.at/v1/station/historical/klima-v1-1h
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In the object &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ds&lt;/code&gt; we can find the dataset used in the Innsbruck example above,
which provides the correct settings for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mode&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;resource_id&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-r highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;subset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resource_id&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;synop-v1-1h&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;##       type       mode resource_id data_format response_formats
## 12 station historical synop-v1-1h     station      geojson|csv
##                                                                       url
## 12 https://dataset.api.hub.geosphere.at/v1/station/historical/synop-v1-1h
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;station-metadata&quot;&gt;Station metadata&lt;/h2&gt;

&lt;p&gt;Once the appropriate &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mode&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;resource_id&lt;/code&gt; for the desired dataset are
identified, additional metadata can be retrieved using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gs_metadata()&lt;/code&gt;. This
function returns a named list with all details provided by the API.&lt;/p&gt;

&lt;div class=&quot;language-r highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gs_metadata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;historical&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resource_id&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;synop-v1-1h&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;station&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;##  [1] &quot;title&quot;            &quot;parameters&quot;       &quot;frequency&quot;        &quot;type&quot;             &quot;mode&quot;             &quot;response_formats&quot;
##  [7] &quot;start_time&quot;       &quot;end_time&quot;         &quot;stations&quot;         &quot;id_type&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;title&lt;/code&gt;: Title of the data set.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;frequency&lt;/code&gt;: Temporal resolution (observation frequency).&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;start_time&lt;/code&gt;/&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;end_time&lt;/code&gt;: Period for which this data set is available. Note that
  not all tations/parameters are available for the entire period!&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stations&lt;/code&gt;: List of all available stations.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;parameters&lt;/code&gt;: List of available parameters with description (German only).&lt;/li&gt;
  &lt;li&gt;…&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two of the most useful elements in the metadata are &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stations&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;parameters&lt;/code&gt;.
The parameters element is a data frame that includes the name (used when
retrieving data via the parameters argument in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gs_stationdata()&lt;/code&gt;), a long name,
a German description, and the corresponding measurement units.&lt;/p&gt;

&lt;div class=&quot;language-r highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;subset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;parameters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%in%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;T&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Td&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ff&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;##    name           long_name                                                                   desc unit
## 39    T      Lufttemperatur                                                         Lufttemperatur   °C
## 40   Td  Taupunkttemperatur                       Taupunkt (bis 2001/06/19 tw. mit rel beschickt!)   °C
## 57   ff Windgeschwindigkeit Windgeschwindigkeit in 1/10 m/s (wird umgerechnet, wenn Knoten: *5.14)  m/s
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stations&lt;/code&gt; meta information is returned as a simple feature data.frame looking
as follows:&lt;/p&gt;

&lt;div class=&quot;language-r highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stations&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;## Simple feature collection with 6 features and 8 fields
## Geometry type: POINT
## Dimension:     XY
## Bounding box:  xmin: 9.848611 ymin: 47.1625 xmax: 15.36694 ymax: 48.69083
## Geodetic CRS:  WGS 84
##         type    id             name            state altitude valid_from   valid_to is_active
## 1 INDIVIDUAL 11330        MAYRHOFEN            Tirol      640 2007-08-28 2100-01-01      TRUE
## 2 INDIVIDUAL 11328       ACHENKIRCH            Tirol      904 1998-09-24 2016-10-04     FALSE
## 3 INDIVIDUAL 11375           AFLENZ       Steiermark      783 1992-10-08 2100-01-01      TRUE
## 4 INDIVIDUAL 11157 AIGEN IM ENNSTAL       Steiermark      641 1972-01-01 2100-01-01      TRUE
## 5 INDIVIDUAL 11301    ALBERSCHWENDE       Vorarlberg      715 1996-01-16 2100-01-01      TRUE
## 6 INDIVIDUAL 11019      ALLENTSTEIG Niederösterreich      599 1988-05-30 2100-01-01      TRUE
##                    geometry
## 1  POINT (11.85167 47.1625)
## 2 POINT (11.70528 47.53222)
## 3 POINT (15.24083 47.54583)
## 4 POINT (14.13833 47.53278)
## 5  POINT (9.848611 47.4575)
## 6 POINT (15.36694 48.69083)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Along with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;id&lt;/code&gt;, the unique identifier used when calling &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gs_stationdata()&lt;/code&gt; via
on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;station_ids&lt;/code&gt; argument, the API provides additional information about each
station. Since the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stations&lt;/code&gt; are provided as a simple feature data frame, it is
easy to visualize their locations or search for specific stations of interest.&lt;/p&gt;

&lt;div class=&quot;language-r highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Plotting altitude&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stations&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;altitude&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pch&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;19&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://retostauffer.org/images/posts/2024-01-26-gsdata/station_overview.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;For more examples and a more comprehensive overview of all features of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gsdata&lt;/code&gt; package please
have a look at the &lt;a href=&quot;https://retostauffer.github.io/gsdata&quot;&gt;documentation&lt;/a&gt;.&lt;/p&gt;

</content>

			
				<category term="news" />
			
			
				<category term="R" />
			
				<category term="weather data" />
			
				<category term="meteorology" />
			
				<category term="climatology" />
			
				<category term="GeoSphere" />
			

			<published>2024-01-26T00:00:00+01:00</published>
		</entry>
	
		<entry>
			<id>https://retostauffer.org/news/white-christmas/</id>
			<title>White Christmas in Innsbruck?</title>
			<link href="https://retostauffer.org/news/white-christmas/" rel="alternate" type="text/html" title="White Christmas in Innsbruck?" />
			<updated>2022-12-16T00:00:00+01:00</updated>

			
				
				<author>
					
						<name>reto</name>
					
					
					
				</author>
			
			<summary>Will we have a white Christmas in Innsbruck in 2022? As of nine days before Christmas, the answer has become quite clear. A machine-learning model that combines atmospheric science, meteorological observations and statistical expertise gave the answer how high (or low) the probability of waking up in a white landscape on December 24, 2022, is.</summary>
			<content type="html" xml:base="https://retostauffer.org/news/white-christmas/">&lt;p&gt;At this specific time of the year, many of us are interested in the question:
Will we have a white Christmas? To understand how this question can be answered
one first needs to understand how weather can be forecasted. Our atmosphere is
a very complex and chaotic system, but is based on physical principles which
are - in large parts - well understood. Starting out from the current state of
the atmosphere, i.e., the current weather around the globe, the physical
principles can be used to calculate the state of the atmosphere in a few hours
or days. This is known as numerical weather prediction (NWP).&lt;/p&gt;

&lt;p&gt;Nowadays, this is done using high-performance supercomputers which run NWP
models to forecast the weather up to several weeks ahead. As neither the
current state of the atmosphere nor all involved physical processes are known
exactly and certain technical or numerical simplifications are required, these
NWPs are subject to some uncertainties. This is especially true for long
forecast horizons (e.g., predicting the weather nine days ahead) as errors
naturally grow over time.&lt;/p&gt;

&lt;p&gt;However, these errors can often be corrected with expert knowledge, thus
improving the accuracy of the forecast. Meteorologists practice interpreting
NWP output and make corrections if needed. E.g., if the NWP always predicts
slightly too cold temperatures in a specific weather situation, the expert can
correct the most recent forecast if the same situation happens again based on
their profound knowledge about previous events. An alternative way is to use
machine-learning techniques following the same idea. Based on historical NWP
forecasts and observations, the algorithm learns in which situations the NWP
was wrong and allows to adjust incoming forecasts accordingly if needed.&lt;/p&gt;

&lt;p&gt;As this work is a cooperation between different departments at the Universität
Innsbruck, we made use of both worlds. While &lt;a href=&quot;https://www.uibk.ac.at/en/acinn/people/georg-mayr/&quot;&gt;Georg J.
Mayr&lt;/a&gt; (Professor at the
Department of Atmospheric and Cryospheric Sciences) manually analyzed the
latest forecasts using his expert knowledge in synoptics, &lt;a href=&quot;https://www.zeileis.org&quot;&gt;Achim
Zeileis&lt;/a&gt; (Professor at the Department of Statistics)
and &lt;a href=&quot;https://retostauffer.org&quot;&gt;Reto Stauffer&lt;/a&gt; (Assistant Professor at the
Digital Science Center and the Department of Statistics) implemented the
machine-learning algorithm to tackle the question.&lt;/p&gt;

&lt;h3 id=&quot;defining-the-target&quot;&gt;Defining the target&lt;/h3&gt;

&lt;p&gt;To have an objective target, we defined ‘white Christmas in Innsbruck’ as
having a closed snow cover with a snow depth of one centimeter or more at
&lt;a href=&quot;https://www.openstreetmap.org/search?query=innsbruck%20airport#map=14/47.2603/11.34388&amp;amp;layers=N&quot;&gt;Innsbruck Airport&lt;/a&gt;
on December 24, 0600 UTC (seven o’clock local time).&lt;/p&gt;

&lt;h3 id=&quot;data&quot;&gt;Data&lt;/h3&gt;

&lt;p&gt;For training the machine-learning model, historical NWP forecasts and
observations from the most recent seven years are used, plus/minus 20 days
around Christmas (December 4 to January 13), resulting in a total sample size
of N=259.&lt;/p&gt;

&lt;p&gt;The observations come from a weather station at Innsbruck Airport, reporting
snow depth at 0600 UTC on a daily basis which are turned into a binary
variable. If a closed snow cover with a snow depth of one centimeter or more is
observed, the snow observation is “white”, or “no” otherwise.&lt;/p&gt;

&lt;p&gt;The NWP forecasts are taken from the
&lt;a href=&quot;https://www.ecmwf.int/&quot;&gt;European Centre for Medium-Range Weather Forecasts&lt;/a&gt; (ECMWF) ensemble prediction system (0000 UTC run). As the latest
ensemble forecast run is the one from December 15 when this blog post goes
online, forecasts up to +222 hours (nine days and six hours) are used to be able to
predict December 24, 2022, 0600 UTC.&lt;/p&gt;

&lt;p&gt;A wide range of different variables from the NWP have been extracted such as
temperatures at ground level and the lower atmosphere, cloud cover,
precipitation and snowfall, or humidity. In addition, aggregated variables have
been calculated covering the full forecast horizon (up to +222 hours) or the three
days before the forecast step of interest (+150 hours to +222 hours) including
aggregated minima, maxima, averages, and/or sums, resulting in M=92 different input
variables for the model.&lt;/p&gt;

&lt;h3 id=&quot;methodology-random-forests&quot;&gt;Methodology: Random forests&lt;/h3&gt;

&lt;p&gt;As the method of choice, a random forest is used, a powerful and flexible, yet
robust, machine-learning algorithm. To give a brief introduction to random
forests: A random forest consists of a series of individual (but all slightly
different) trees.&lt;/p&gt;

&lt;p&gt;Each conditional inference tree is based on randomly selected variables from
the NWP (15 out of 92). In each iteration it is tested which of the input variables
shows the strongest dependence to the target variable. If there is at least
one, a binary split is performed on the one with the highest dependency,
splitting the data into two subsets resulting in two new nodes. This process is
repeated until there is no more dependency between the target and the input
variables, or other stopping criteria are met. The last node after each split
is also called a leaf containing a series of observations which either fall
into “white” or “no”. Thus, the relative frequency (or probability) observing
“white” can be calculated in each leaf.&lt;/p&gt;

&lt;p&gt;Many of these trees build a random forest. For this application, 5000 individual
trees are used, whereof one tree is shown exemplarily below.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://retostauffer.org/images/posts/2022-12-16-white-christmas/example-forest.svg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Once the random forest is estimated, variable importance can be calculated by
performing a random permutation test. Without going into details: The more
important a variable, the stronger the accuracy of the random forest decreases.
The image below shows the mean decrease in accuracy of the 15 most important
variables of the estimated random forest.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://retostauffer.org/images/posts/2022-12-16-white-christmas/variable-importance.svg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Once a new NWP forecast becomes available, we can predict the outcome by
putting the new forecast into each of the 5000 trees and check in which leaf (final
node) the new observation will fall into. Averaging over the outcome of all
trees gives the final probability of the event happening (“white”) or not
happening (“no”).&lt;/p&gt;

&lt;h3 id=&quot;prediction-will-there-be-a-white-christmas-in-innsbruck&quot;&gt;Prediction: Will there be a white Christmas in Innsbruck?&lt;/h3&gt;

&lt;p&gt;To finally answer the question, a prediction was made for Christmas (December
24, 2022, 0600 UTC) based on the latest NWP forecast (initialized December 15,
2022, 0000 UTC). The random forest returns a probability of 8.8%. Given the
information we have today, nine days before Christmas, the chances of having a
closed snow cover with a snow depth of one centimeter or more is not zero, but
not large either.&lt;/p&gt;

&lt;p&gt;Does the expert meteorologist agree with the algorithm? Independently from the
machine-learning approach, Georg J. Mayr was going trough a vast amount of
weather forecast maps on December 15, 2022. He came to the conclusion that in
the days leading up to the event the notorious “Christmas thaw” weather will
erase the remaining white and gave the probability of a white Christmas of less
than 5%; close to the result from the random forest.&lt;/p&gt;

&lt;p&gt;To know for sure whether December 24 will be a white Christmas and how good the
forecasts are, we will have to wait for nine days (and watch the latest
forecasts). To be able to give such a clear answer with our application is an
exciting development. If you are interested in learning more about some of the
topics covered but in much greater detail, please have a look at the suggested
references below.&lt;/p&gt;

&lt;h2 id=&quot;how-to-cite&quot;&gt;How to cite&lt;/h2&gt;

&lt;p&gt;Reto Stauffer (2022). “White Christmas in Innsbruck?”,
&lt;em&gt;Digital Science Center Blog&lt;/em&gt;, &lt;a href=&quot;https://doi.org/10.48763/000004&quot;&gt;10.48763/000004&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Schlosser L, Hothorn T, Stauffer R, Zeileis A (2019). “Distributional
regression forests for probabilistic precipitation forecasting in complex
terrain”. &lt;em&gt;Annals of Applied Statistics&lt;/em&gt;, &lt;strong&gt;13&lt;/strong&gt;(3), 1564–1589.
doi:&lt;a href=&quot;https://doi.org/10.1214/19-AOAS1247&quot;&gt;10.1214/19-AOAS1247&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Stauffer R, Mayr GJ, Messner JW, Zeileis A (2018). “Hourly Probabilistic Snow
Forecasts over Complex Terrain: A Hybrid Ensemble Postprocessing Approach”.
&lt;em&gt;Advances in Statistical Climatoloy, Meteorology and Oceanography&lt;/em&gt;, &lt;strong&gt;4&lt;/strong&gt;(1/2),
65-86. doi:&lt;a href=&quot;https://doi.org/10.5194/ascmo-4-65-2018&quot;&gt;10.5194/ascmo-4-65-2018&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Stauffer R, Umlauf N, Messner JW, Mayr GJ, Zeileis A (2017b). “Ensemble
Postprocessing of Daily Precipitation Sums over Complex Terrain Using
Censored High-Resolution Standardized Anomalies”. &lt;em&gt;Monthly Weather Review&lt;/em&gt;,
&lt;strong&gt;145&lt;/strong&gt;(3), 955–969. doi:&lt;a href=&quot;https://doi.org/10.1175/MWR-D-16-0260.1&quot;&gt;10.1175/MWR-D-16-0260.1&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
</content>

			
				<category term="news" />
			
			
				<category term="snow" />
			
				<category term="machine-learning" />
			
				<category term="decision tree" />
			

			<published>2022-12-16T00:00:00+01:00</published>
		</entry>
	
		<entry>
			<id>https://retostauffer.org/research/useR-contribution/</id>
			<title>useR!2021 Contribution</title>
			<link href="https://retostauffer.org/research/useR-contribution/" rel="alternate" type="text/html" title="useR!2021 Contribution" />
			<updated>2021-07-06T00:00:00+02:00</updated>

			
				
				<author>
					
						<name>reto</name>
					
					
					
				</author>
			
			<summary>Interested in getting some insights into how we are teaching an introductory programming course with R?</summary>
			<content type="html" xml:base="https://retostauffer.org/research/useR-contribution/">&lt;!--more--&gt;

&lt;p&gt;Today we have had the chance to give some insights about our teaching
at the &lt;a href=&quot;https://uibk.ac.at/disc&quot;&gt;Digital Science Center&lt;/a&gt; of the
&lt;a href=&quot;https://uibk.ac.at&quot;&gt;Universität Innsbruck&lt;/a&gt;, to be more precise into how we teach
an introductory programming course with &lt;em&gt;R&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;In case you have not had the chance to participate at
&lt;a href=&quot;https://user2021.r-project.org/&quot;&gt;the &lt;em&gt;R&lt;/em&gt; conference&lt;/a&gt; feel free to
watch our 5 minute elevators pitch on &lt;a href=&quot;https://user2021.r-project.org/&quot;&gt;youtube&lt;/a&gt;.
The slides to the presentation are also &lt;a href=&quot;/files/2021-07-06_useR2021.pdf&quot;&gt;available as pdf&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thanks to my coauthors
&lt;a href=&quot;https://www.linkedin.com/in/chimiakopoka/&quot;&gt;Joanna&lt;/a&gt;,
&lt;a href=&quot;https://rodriguez-r.com/&quot;&gt;Miguel&lt;/a&gt;,
and &lt;a href=&quot;https://www.zeileis.org/&quot;&gt;Achim&lt;/a&gt;.&lt;/p&gt;

</content>

			
				<category term="research" />
			
			
				<category term="post format" />
			

			<published>2021-07-06T00:00:00+02:00</published>
		</entry>
	
		<entry>
			<id>https://retostauffer.org/techreport/colorspace-arXiv/</id>
			<title>colorspace: A Toolbox for Manipulating and Assessing Colors and Palettes</title>
			<link href="https://retostauffer.org/techreport/colorspace-arXiv/" rel="alternate" type="text/html" title="colorspace: A Toolbox for Manipulating and Assessing Colors and Palettes" />
			<updated>2019-03-18T00:00:00+01:00</updated>

			
				
				<author>
					
						<name>reto</name>
					
					
					
				</author>
			
			<summary>Over the past few months, if not even years, the R colorspace package has been extended and useful new features have been added. Alongside with the current release of the R software package a working paper has become available!</summary>
			<content type="html" xml:base="https://retostauffer.org/techreport/colorspace-arXiv/">&lt;p&gt;&lt;strong&gt;Authors:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://eeecon.uibk.ac.at/~zeileis&quot;&gt;Achim Zeileis&lt;/a&gt;, Universität Innsbruck&lt;/li&gt;
  &lt;li&gt;Jason C. Fisher, U.S. Geological Survey&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://statmath.wu.ac.at/~hornik/&quot;&gt;Kurt Hornik&lt;/a&gt;, WU Wirtschaftsuniversität Wien&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.stat.auckland.ac.nz/~ihaka/&quot;&gt;Ross Ihaka&lt;/a&gt;, University of Auckland&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://clairemcwhite.github.io/&quot;&gt;Claire D. McWhite&lt;/a&gt;, The University of Texas at Austin&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.stat.auckland.ac.nz/~paul/&quot;&gt;Paul Murrell&lt;/a&gt;, University of Auckland&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://retostauffer.org&quot;&gt;Reto Stauffer&lt;/a&gt;, Universität Innsbruck&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://serialmentor.com/&quot;&gt;Claus O. Wilke&lt;/a&gt;, The University of Texas at Austin&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Abstract:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;R&lt;/em&gt; package colorspace provides a flexible toolbox for
selecting individual colors or color palettes, manipulating these colors, and
employing them in statistical graphics and data visualizations. In particular,
the package provides a broad range of color palettes based on the HCL
(Hue-Chroma-Luminance) color space. The three HCL dimensions have been shown to
match those of the human visual system very well, thus facilitating intuitive
selection of color palettes through trajectories in this space. Using the HCL
color model general strategies for three types of palettes are implemented: (1)
Qualitative for coding categorical information, i.e., where no particular
ordering of categories is available. (2) Sequential for coding ordered/numeric
information, i.e., going from high to low (or vice versa). (3) Diverging for
coding ordered/numeric information around a central neutral value, i.e., where
colors diverge from neutral to two extremes. To aid selection and application
of these palettes the package also contains scales for use with ggplot2, shiny
(and tcltk) apps for interactive exploration, visualizations of palette
properties, accompanying manipulation utilities (like desaturation and
lighten/darken), and emulation of color vision deficiencies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;More information:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://arxiv.org/abs/1903.06490&quot;&gt;Workingpaper available on arXiv.org&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://CRAN.R-project.org/package=colorspace&quot;&gt;The &lt;em&gt;R&lt;/em&gt; package on CRAN&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://colorspace.R-Forge.R-project.org/&quot;&gt;Detailed Package documentation (R-Forge.R-project.org)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;The article has been submitted to the &lt;a href=&quot;https://www.jstatsoft.org&quot;&gt;Journal of Statistical Software&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</content>

			
				<category term="techreport" />
			
			
				<category term="colorspace" />
			
				<category term="R" />
			
				<category term="software" />
			

			<published>2019-03-18T00:00:00+01:00</published>
		</entry>
	
		<entry>
			<id>https://retostauffer.org/software/PyGFSV2-beta/</id>
			<title>Convenient GFS Reforecast V2 Downloader</title>
			<link href="https://retostauffer.org/software/PyGFSV2-beta/" rel="alternate" type="text/html" title="Convenient GFS Reforecast V2 Downloader" />
			<updated>2019-01-28T00:00:00+01:00</updated>

			
				
				<author>
					
						<name>reto</name>
					
					
					
				</author>
			
			<summary>Some might have used the Python GFS reforecast version 2 downloader I wrote some years ago. Today I made some smaller adjustments (fixed two smaller bugs) and made the code python3 ready. You should now also be able to download the reforecasts using python3.</summary>
			<content type="html" xml:base="https://retostauffer.org/software/PyGFSV2-beta/">&lt;h1 id=&quot;pygfsv2-package-in-beta&quot;&gt;PyGFSV2 Package in Beta&lt;/h1&gt;

&lt;p&gt;Today I fixed some smaller issues in the PyGFSV2 code (thanks to Naschi) and
made the code python 3 ready. However, have not yet had time for extensive
testing!&lt;/p&gt;

&lt;p&gt;Feel free to use it and do not hesitate to contact me if there are any problems
with the code! Or report problems &lt;a href=&quot;https://github.com/retostauffer/PyGFSV2/issues&quot;&gt;as issues on github&lt;/a&gt;.&lt;/p&gt;
</content>

			
				<category term="software" />
			
			
				<category term="python" />
			

			<published>2019-01-28T00:00:00+01:00</published>
		</entry>
	
		<entry>
			<id>https://retostauffer.org/code/Download-ERA5/</id>
			<title>Downloading ERA-5 Data</title>
			<link href="https://retostauffer.org/code/Download-ERA5/" rel="alternate" type="text/html" title="Downloading ERA-5 Data" />
			<updated>2018-12-15T00:00:00+01:00</updated>

			
				
				<author>
					
						<name>reto</name>
					
					
					
				</author>
			
			<summary>Quite recently the European Centre for Medium-Range Weather Forecasts (ECMWF) started publishing the new ERA-5 reanalysis data set. In cooperation with the European Union (Copernicus) this data set is freely available to everyone! And even better: a nice API grants easy access to this wonderful data set. This is a brief introduction on how to access ERA-5 data</summary>
			<content type="html" xml:base="https://retostauffer.org/code/Download-ERA5/">&lt;p&gt;This work by &lt;b&gt;Reto Stauffer (2025)&lt;/b&gt; is licensed under the &lt;b&gt;GNU General Public License v2&lt;/b&gt;. If you improve and/or extend the code it would be great to send me a message and the extensions such that I can include the changes in the original repository.&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;short-guide-for-downloading-era5&quot;&gt;Short guide for downloading ERA5&lt;/h2&gt;

&lt;p&gt;Some time ago I have written a short introduction on
&lt;a href=&quot;https://retostauffer.org/code/Download-ERA-INTERIM/&quot;&gt;how to download ERA INTERIM data&lt;/a&gt;
from &lt;a href=&quot;https://www.ecmwf.int/en/forecasts/datasets/reanalysis-datasets/era-interim&quot;&gt;ecmwf.int&lt;/a&gt;.
ERA INTERIM was the fourth version of ECMWFs global reanalysis data set. Just
recently (mid 2018) the ECMWF started publishing the new ERA-5 data set with
a spatial resolution of about 32 km times 32 kilometers.&lt;/p&gt;

&lt;p&gt;Please note that this data set is still in a pre-release state. Every now and then
some fields are getting updated as some problems have been identified in the data.
The data set is currently going back to January 2000 but will be further extended
into the past.&lt;/p&gt;

&lt;p&gt;Access to ERA-5 is very similar to accessing ERA INTERIM, however, the new data
set is redistributed over the &lt;a href=&quot;https://cds.climate.copernicus.eu/&quot;&gt;Copernicus Climate Data Store&lt;/a&gt;.
Even if access via the ECMWF public data access portal is still possible it is not
recommended to do so as it will be shut down in the near future.&lt;/p&gt;

&lt;p&gt;All we need to download data:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A valid CDS user account and create a local file containing the user token.&lt;/li&gt;
  &lt;li&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cdsapi&lt;/code&gt; python package plus a few lines of python code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even if you are not yet familiar to python you’ll see that it is pretty simple!&lt;/p&gt;

&lt;h2 id=&quot;create-a-user-account-get-your-api-key&quot;&gt;Create a user account, get your API key&lt;/h2&gt;

&lt;p&gt;If you don’t own a user account yet &lt;a href=&quot;https://cds.climate.copernicus.eu/user/register?destination=/drupal_auth_check&quot;&gt;create a new account&lt;/a&gt; on the CDS website.
After activating your account use your new account to log in. Your user name
will be show in the top right corner. You can now enter your user profile
by clicking on your user name. On the profile you’ll find your user id
(&lt;strong&gt;UID&lt;/strong&gt;) and your personal &lt;strong&gt;API Key&lt;/strong&gt;.&lt;/p&gt;

&lt;h2 id=&quot;create-local-key-file&quot;&gt;Create local key file&lt;/h2&gt;

&lt;p&gt;For batch script data downloads you’ll have to create a local ASCII file with
your user information (UID, API key) which is used by the python package
(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cdsapi&lt;/code&gt;). To do so (linux) simply create a file called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.cdsapirc&lt;/code&gt; in
your home directory and add the following two lines:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;url: https://cds.climate.copernicus.eu/api/v2
key: 1234:abcdefghij-134-abcdefgadf-82391b9d3f
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;where &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1234&lt;/code&gt; is your personal user ID (UID), the part behind the colon your
personal API key. Line one simply contains the URL to the web API.
More details &lt;a href=&quot;https://cds.climate.copernicus.eu/api-how-to&quot;&gt;can be found here&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;install-cdsapi-package&quot;&gt;Install cdsapi package&lt;/h2&gt;

&lt;p&gt;What you’ll need next is the python package &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cdsapi&lt;/code&gt;. As it is available
on &lt;a href=&quot;https://pypi.org/project/cdsapi/&quot;&gt;PyPI&lt;/a&gt; you can simply install it using
your preferred python package installer, e.g., pip:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pip install cdsapi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For the sake of completeness: I am using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cdsapi 2.18.4&lt;/code&gt; at the moment.&lt;/p&gt;

&lt;h2 id=&quot;write-your-first-data-request&quot;&gt;Write your first data request&lt;/h2&gt;

&lt;p&gt;To get data you’ll have to write a small python script which sends
requests to the CDS servers. Here is one simple example how the
python scripts will look like:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# Import cdsapi
import cdsapi
# Open a new Client instance
c = cdsapi.Client()
# Send your request (download data)
c.retrieve(&apos;reanalysis-era5-single-levels&apos;, {
        &apos;product_type&apos;: &apos;reanalysis&apos;,
        &apos;variable&apos;:     &apos;orography&apos;,
        &apos;year&apos;:         &apos;2016&apos;,
        &apos;month&apos;:        &apos;01&apos;,
        &apos;day&apos;:          &apos;01&apos;,
        &apos;time&apos;:         &apos;00:00&apos;
    }, &apos;orography.grib&apos;)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Copy the lines above into a python script (e.g., &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;orography.py&lt;/code&gt;) and
execute it (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;python orography.py&lt;/code&gt;). In this simple case I am requesting
orography (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;variable&lt;/code&gt;) reanalysis (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;product_type&lt;/code&gt;) data for January 1, 2016 00:00 UTC
(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;year&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;month&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;day&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;time&lt;/code&gt;). Orography is a single-level variable and thus
identified by the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reanalysis-era5-single-levels&lt;/code&gt; product keyword.
Once you executed this script you should now have a file called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;orography.grib&lt;/code&gt;
just next to your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;orography.py&lt;/code&gt; script file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; the &lt;a href=&quot;https://cds.climate.copernicus.eu&quot;&gt;CDS&lt;/a&gt; provides a nice
web interface where you can create these requests by selecting the parameters
and time periods you need. Under &lt;strong&gt;Show API Request&lt;/strong&gt; you’ll see the request
(as shown above) for your custom selection, but not all options are shown.
Two different data sets are available:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels?tab=overview&quot;&gt;ERA-5 single-level data&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-pressure-levels?tab=overview&quot;&gt;ERA-5 pressure-level data&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;make-a-more-useful-request&quot;&gt;Make a more useful request&lt;/h2&gt;

&lt;p&gt;Let’s assume we are interested in the 00 UTC temperature and geopotential height
of the 900 and 700 hectopascal level for 2017 over Europe for some reason.
The corresponding request looks like this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# Import cdsapi and create a Client instance
import cdsapi
c = cdsapi.Client()
# More complex request
c.retrieve(&quot;reanalysis-era5-pressure-levels&quot;, {
        &quot;product_type&quot;:   &quot;reanalysis&quot;,
        &quot;format&quot;:         &quot;netcdf&quot;,
        &quot;area&quot;:           &quot;52.00/2.00/40.00/20.00&quot;,
        &quot;variable&quot;:       [&quot;geopotential&quot;,&quot;temperature&quot;],
        &quot;pressure_level&quot;: [&quot;700&quot;,&quot;900&quot;],
        &quot;year&quot;:           &quot;2017&quot;,
        &quot;month&quot;:          [&quot;01&quot;,&quot;02&quot;,&quot;03&quot;,&quot;04&quot;,&quot;05&quot;,&quot;06&quot;,&quot;07&quot;,&quot;08&quot;,&quot;09&quot;,&quot;10&quot;,&quot;11&quot;,&quot;12&quot;],
        &quot;day&quot;:            [&quot;01&quot;,&quot;02&quot;,&quot;03&quot;,&quot;04&quot;,&quot;05&quot;,&quot;06&quot;,&quot;07&quot;,&quot;08&quot;,&quot;09&quot;,&quot;10&quot;,&quot;11&quot;,
                           &quot;12&quot;,&quot;13&quot;,&quot;14&quot;,&quot;15&quot;,&quot;16&quot;,&quot;17&quot;,&quot;18&quot;,&quot;19&quot;,&quot;20&quot;,&quot;21&quot;,&quot;22&quot;,
                           &quot;23&quot;,&quot;24&quot;,&quot;25&quot;,&quot;26&quot;,&quot;27&quot;,&quot;28&quot;,&quot;29&quot;,&quot;30&quot;,&quot;31&quot;],
        &quot;time&quot;:           &quot;00&quot;
    }, &quot;output.nc&quot;)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;Product identifier: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reanalysis-era5-pressure-levels&lt;/code&gt; as we are interested in pressure level data&lt;/li&gt;
  &lt;li&gt;Product type: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reanalysis&lt;/code&gt; (as before)&lt;/li&gt;
  &lt;li&gt;Format: instead of downloading grib1 data we would like to have &lt;strong&gt;NetCDF&lt;/strong&gt; data.
  This is nice as the grib1 file format is a bit unhandy sometimes and can be
  specified using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;format&lt;/code&gt; key.&lt;/li&gt;
  &lt;li&gt;Spatial extent: the keyword &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;area&lt;/code&gt; allows to download a very specific subset.
  The definition is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;N/W/S/E&lt;/code&gt; in degrees longitude and latitude
  (&lt;a href=&quot;https://confluence.ecmwf.int/display/CKB/C3S+ERA5%3A+Web+API+to+CDS+API&quot;&gt;see API manual&lt;/a&gt;).
  Negative values correspond to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;S&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;W&lt;/code&gt;. In the example above a domain over Europe.&lt;/li&gt;
  &lt;li&gt;Fields: we would like to get geopotential height and temperature (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;variable&lt;/code&gt;)
  on two levels, namely 900 and 700 hectopascal (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pressure_level&lt;/code&gt;).&lt;/li&gt;
  &lt;li&gt;As we are interested in 00 UTC data for 2018 we simply specify &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;time&quot;:&quot;00&quot;&lt;/code&gt;,
  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;year&quot;:&quot;2018&quot;&lt;/code&gt;, all months (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;01&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;12&lt;/code&gt;) and all days (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;01&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;31&lt;/code&gt;).
  Don’t worry that some combinations do not exist (e.g., February 31), the
  API will simply ignore these fields.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the end you should get the output file &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;output.nc&lt;/code&gt;. To drop some numbers:
the output file is of about &lt;strong&gt;10 MB&lt;/strong&gt; in this case and the whole request took
me &lt;strong&gt;less than five minutes&lt;/strong&gt;.&lt;/p&gt;

&lt;h2 id=&quot;batch-scripting-the-requests&quot;&gt;Batch-scripting the requests&lt;/h2&gt;

&lt;p&gt;Rather than copy-pasting API requests you can, of course, also write some
more fancy scripts. The script below is a script I’ve written few weeks ago
to download a set of files for one of our current studies.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Reto’s &lt;a href=&quot;https://retostauffer.org/data/ERA5_Downloader.py&quot;&gt;ERA5 Downloader&lt;/a&gt;
       (&lt;a href=&quot;https://retostauffer.org/data/ERA5_Downloader.py&quot;&gt;download the script here&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feel free to use, modify and redistribute the script (GPL2 license). Please note
that the script is quite likely not free of bugs. If you find some please let me know :).&lt;/p&gt;

&lt;p&gt;Some of the features:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Should be python3 and python2 ready.&lt;/li&gt;
  &lt;li&gt;Provides some help (call &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;python ERA5_Downloader.py --help&lt;/code&gt;).&lt;/li&gt;
  &lt;li&gt;Downloads one parameter at a time.&lt;/li&gt;
  &lt;li&gt;Is downloading data in junks (month/year) stored in a sub-folder
 called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;era5_data&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Checks whether a file has already been downloaded.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Is subsetting Europe!&lt;/strong&gt; The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;area&lt;/code&gt; is hard-coded in the script, needs to be
adjusted depending on what you want to have.&lt;/li&gt;
  &lt;li&gt;This script has been written for one of my applications in only few quarter
of minutes and is far away from beeing perfect or super flexible. However, it
might be a good starter if you are looking for a script to start with.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;output-of-era5_downloaderpy-help&quot;&gt;Output of ERA5_Downloader.py –help&lt;/h2&gt;

&lt;p&gt;If you missed the link above: the &lt;a href=&quot;https://retostauffer.org/data/ERA5_Downloader.py&quot;&gt;ERA5 Downloader&lt;/a&gt;
can be &lt;a href=&quot;https://retostauffer.org/data/ERA5_Downloader.py&quot;&gt;downloaded here (click)&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Usage: Usage:

    ERA5_Downloader.py --years &amp;lt;years&amp;gt; --parameter &amp;lt;parameter&amp;gt; --level &amp;lt;level&amp;gt;
    ERA5_Downloader.py -y &amp;lt;years&amp;gt; -p &amp;lt;parameter&amp;gt; -l &amp;lt;level&amp;gt;

    Downloading ERA5 reanalysis data from Copernicus Climate Data
    Services. NOTE: Not yet made for ensemble ERA5!

    Requires `cdsapi` to be installed (python package to access
    Copernicus Climate Data Services, CDS).

    How to install cdsapi and the required API key:
    * https://cds.climate.copernicus.eu/api-how-to

    Available parameters for &quot;single level&quot; (-t/--type sf):
    * https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-pressure-levels?tab=form

    Available parameters for &quot;pressure level&quot; (-t/--type pl):
    * https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-pressure-levels?tab=form

    Usage examples:

    10m wind speed for the year 2018
    &amp;gt;&amp;gt;&amp;gt; python ERA5_Downloader.py --years 2018 --parameter 10m_u_component_of_wind

    10m wind speed for 2010 and 2018
    &amp;gt;&amp;gt;&amp;gt; python ERA5_Downloader.py --years 2010,2018 --parameter 10m_u_component_of_wind

    10m wind speed for 2008, 2009, 2010, ..., 2018
    &amp;gt;&amp;gt;&amp;gt; python ERA5_Downloader.py --years 2008-2018 --parameter 10m_u_component_of_wind

    700hPa geopotential height, 2018
    &amp;gt;&amp;gt;&amp;gt; python ERA5_Downloader.py --years 2018 --parameter geopotential --level 700
    
    

Options:
  -h, --help            show this help message and exit
  -y YEARS, --years=YEARS
                        years for which the data should be downloaded. Can
                        either be a single year (e.g., 2010), a comma
                        separated list (e.g., 2010,2011), or a sequence of the
                        form &amp;lt;bgn&amp;gt;-&amp;lt;end&amp;gt; (e.g., 2010-2018; 2010 to 2018).
  -p PARAM, --parameter=PARAM
                        the parameter/variable to be downloaded. Please check
                        the cds website to see what&apos;s availabe.
  -l LEVEL, --level=LEVEL
                        level, only for pressure level data. For &quot;single level
                        data&quot; (e.g., surface level variables) do not set this
                        parameter!
  -t, --test            development flag. If set, only one day (January 1th of
                        the first year) will be downloaded before the script
                        stops. The output file will be labeled with &quot;_test_&quot;.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This work by &lt;b&gt;Reto Stauffer (2025)&lt;/b&gt; is licensed under the &lt;b&gt;GNU General Public License v2&lt;/b&gt;. If you improve and/or extend the code it would be great to send me a message and the extensions such that I can include the changes in the original repository.&lt;br /&gt;&lt;/p&gt;

</content>

			
				<category term="code" />
			
			
				<category term="code" />
			
				<category term="python" />
			
				<category term="data" />
			

			<published>2018-12-15T00:00:00+01:00</published>
		</entry>
	
		<entry>
			<id>https://retostauffer.org/news/python-colorspace-v0.1.0/</id>
			<title>Python colorspace package</title>
			<link href="https://retostauffer.org/news/python-colorspace-v0.1.0/" rel="alternate" type="text/html" title="Python colorspace package" />
			<updated>2018-09-17T00:00:00+02:00</updated>

			
				
				<author>
					
						<name>reto</name>
					
					
					
				</author>
			
			<summary>The R colorspace package exists since quite a while but was only available in R so far. This package (which is in an early beta state at the moment) provides the same features and methods as the R colorspace package in native python code. Give it a shot!</summary>
			<content type="html" xml:base="https://retostauffer.org/news/python-colorspace-v0.1.0/">&lt;p&gt;Some good news for python enthusiasts. I have had some “free time” and decided
to port the &lt;a href=&quot;https://retostauffer.org/software/colorspace&quot;&gt;&lt;em&gt;R&lt;/em&gt; colorspace&lt;/a&gt;
package to python.  The result is the &lt;a href=&quot;https://github.com/retostauffer/python-colorspace&quot;&gt;python
colorspace&lt;/a&gt; package for
&lt;em&gt;Python 2.7&lt;/em&gt; and &lt;em&gt;Python 3.6+&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Today I decided to publish a first &lt;a href=&quot;https://github.com/retostauffer/python-colorspace&quot;&gt;&lt;em&gt;early beta release&lt;/em&gt;
(v0.1.0)&lt;/a&gt;.  There might be
some hilarious bugs (or features) in the current version and not all features
are yet implemented, but should be a working tech demo! If you are interested
you can give it a shot. Feel free to report bugs and/or contribute to this
little project if you want to.&lt;/p&gt;

&lt;p&gt;The documentation is available on
&lt;a href=&quot;https://python-colorspace.readthedocs.io/en/latest/&quot;&gt;readthedocs.io&lt;/a&gt; but needs
some more attention from my side. Not all functions are documented, nothing is
proof-read, and some pages are still empty (e.g., the usage examples).  I’ll
try to work on it as soon as possible.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Package: &lt;a href=&quot;https://github.com/retostauffer/python-colorspace&quot;&gt;https://github.com/retostauffer/python-colorspace&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Documentation: &lt;a href=&quot;https://python-colorspace.readthedocs.io/en/latest/&quot;&gt;https://python-colorspace.readthedocs.io/en/latest/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;More information: &lt;a href=&quot;http://hclwizard.org/&quot;&gt;http://hclwizard.org/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;The &lt;em&gt;R&lt;/em&gt; package: &lt;a href=&quot;https://cran.r-project.org/package=colorspace&quot;&gt;https://cran.r-project.org/package=colorspace&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;what-the-package-does&quot;&gt;What the package does&lt;/h2&gt;

&lt;p&gt;The &lt;a href=&quot;https://github.com/retostauffer/python-colorspace&quot;&gt;colorspace&lt;/a&gt;
provides some handy functions to create and use effective color maps for
scientific data visualization based on the Hue-Chroma-Luminance color space.
In contrast to the widely used Red-Green-Blue color space the HCL color space
is based on how humans perceive colors. The three dimensions of the HCL color space
allow to directly control the three dimensions of color perception and to avoid
“bad” or inefficient color maps which can, in some cases, obscure the data presented
in the figures and make them hard to interpret or even mislead the readers.&lt;/p&gt;

&lt;h2 id=&quot;choose-color-palettes&quot;&gt;Choose Color Palettes&lt;/h2&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;choose_palette()&lt;/code&gt; function provides an interactive TclTk interface to
customize color palettes. Some simple demo plots allow to directly access the
look and feel of the palettes. Furthermore, the interface allows to check
the selected color palettes for possible issues with respect to color vision
deficiencies (color blindness).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://retostauffer.org/images/posts/python-colorspace-gui_v0.1.0.jpg&quot; alt=&quot;Screenshot of the ``choose_palette()`` GUI.&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The GUI returns a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hclpalette&lt;/code&gt; object with a range of standardized methods
to draw a set of colors:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://retostauffer.org/images/posts/python-colorspace-palette1_v0.1.0.jpg&quot; alt=&quot;Draw 3 unique colors from the sequential color palette specified via GUI.&quot; /&gt;&lt;/p&gt;

&lt;p&gt;As the returned object is an object it also allows you to dynamically
draw a different number of colors from the palette, e.g,. 100:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://retostauffer.org/images/posts/python-colorspace-palette2_v0.1.0.jpg&quot; alt=&quot;Draw 100 unique colors from the sequential color palette specified via GUI.&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Or simply return a vector with three HEX colors.  There is even a method to
directly get a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;matplotlib cmap&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;matplotlib.colors.LinearSegmentedColormap&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://retostauffer.org/images/posts/python-colorspace-palette3_v0.1.0.jpg&quot; alt=&quot;Draw a HEX color list from the palette specified via GUI.&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There are some more nice features such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;swatchplot&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;specplot&lt;/code&gt; to
access the palette, functions to simulate color vision deficiencies (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;deutan&lt;/code&gt;,
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;protan&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tritan&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;desaturate&lt;/code&gt;), and more.
The package also includes a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;colorlib&lt;/code&gt; module which allows to easily transform
colors between a set of different color spaces including &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hex&lt;/code&gt; colors, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CIE-XYZ&lt;/code&gt;,
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HCL&lt;/code&gt;, and others.&lt;/p&gt;

&lt;p&gt;Again, it’s a beta! You can blame me, but it would be nice to get some feedback
instead :). Bug-reports and issues welcome which help to fix existing errors and
to improve the package.&lt;/p&gt;

&lt;p&gt;Reto&lt;/p&gt;

</content>

			
				<category term="news" />
			
			
				<category term="news" />
			
				<category term="python" />
			

			<published>2018-09-17T00:00:00+02:00</published>
		</entry>
	
</feed>