Switch between hemispheres#
Many functions within PolarToolkit require knowing whether its working with data in the EPSG 3031 project for Antarctica or the EPSG 3413 projection for the Arctic(including Greenland). These function each have a parameter hemisphere which can be set to either south or north for EPSG 3031 or EPSG 3413, respectively. However, for convenience, there are two other methods than manually setting the hemisphere variable, as well show here.
[1]:
from polartoolkit import fetch, maps, regions
Manually set the hemisphere variable#
For any function which requires knowing it’s projection, you can manually set it with the hemisphere variable. For example, ice velocity data is available for both Greenland and Antarctica, so you can pass hemisphere to pick which version of the grid is returned.
[2]:
grid = fetch.ice_vel(
hemisphere="north",
)
fig = maps.plot_grd(
grid,
hemisphere="north",
region=regions.kangerlussuaq_glacier,
robust=True,
inset=True,
coast=True,
)
fig.show()
Temporarily set for Python session#
If you know everything in your notebook or python file will be related to just one of the hemisphere, you can set a temporary environment variable for your current python session. This can be overwritten by the above manual setting of hemisphere. Note that when we rerun the above function we will now download ice velocity data and make a plot for Antarctica, insteaad of Greenland.
[3]:
import os
os.environ["POLARTOOLKIT_HEMISPHERE"] = "south"
[4]:
grid = fetch.ice_vel()
fig = maps.plot_grd(
grid,
region=regions.ross_ice_shelf,
robust=True,
inset=True,
coast=True,
)
fig.show()
Permanently set#
If you know you will be using PolarToolkit almost entirely for just one of the hemispheres, it makes sense to use an environment variable in your operating system to set the value of hemisphere. If you need to temporarily switch to the other hemisphere, either of the above two options can be used to overwrite the environment variable temporarily.
The name you need to give the environment variable is “POLARTOOLKIT_HEMISPHERE” with a value of either “north” or “south”. This is done different on each operating system.
For Unix or Mac OS, add the following to the end of your .bashrc file (Unix) or .bash_profile (Mac OS):
export POLARTOOLKIT_HEMISPHERE=north
You may need to restart your computer for this to take effect.
For Windows, follow the below instructions:
Launch “Control Panel”
Go to “System” -> “Advanced system settings” -> “Advanced” tab -> “Environment variables” -> “System Variables” (for all users)
Choose “New”
Enter the variable “Name” as POLARTOOLKIT_HEMISPHERE and “Value” either north or south.
[ ]: