Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
267 changes: 267 additions & 0 deletions docs/source/howto/create_quicklooks.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "1ff5dc6d-caec-4303-8c22-684792c6cfe5",
"metadata": {},
"source": [
"# Some dropsonde quicklook examples"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "947b5fe5-e348-4d8c-b6fd-de449fc2aa44",
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'halodrops'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[1], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mhalodrops\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mplotting\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m quicklooks \u001b[38;5;28;01mas\u001b[39;00m ql\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'halodrops'"
]
}
],
"source": [
"from halodrops.plotting import quicklooks as ql"
]
},
{
"cell_type": "markdown",
"id": "6b2d5ef7-5111-4978-99dc-36b6a28fed2c",
"metadata": {},
"source": [
"### Test plotting for EUREC4A data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a3d0cd28-5bce-46d9-abe8-5c45cc32c14e",
"metadata": {},
"outputs": [],
"source": [
"import eurec4a\n",
"from datetime import datetime, date\n",
"from collections import defaultdict\n",
"from functools import reduce\n",
"\n",
"# Access EUREC4A catalog\n",
"cat = eurec4a.get_intake_catalog(use_ipfs=False)\n",
"\n",
"# Get flight segments\n",
"meta = eurec4a.get_flight_segments()\n",
"\n",
"segments = [{**s,\n",
" \"platform_id\": platform_id,\n",
" \"flight_id\": flight_id\n",
" }\n",
" for platform_id, flights in meta.items()\n",
" for flight_id, flight in flights.items()\n",
" for s in flight[\"segments\"]\n",
" ]\n",
"\n",
"segments_by_segment_id = {s[\"segment_id\"]: s for s in segments}\n",
"segments_ordered_by_start_time = list(sorted(segments, key=lambda s: s[\"start\"]))\n",
"\n",
"circles_Jan24 = [s[\"segment_id\"]\n",
" for s in segments_ordered_by_start_time\n",
" if \"circle\" in s[\"kinds\"]\n",
" and s[\"start\"].date() == date(2020,1,24)\n",
" and s[\"platform_id\"] == \"HALO\"\n",
" ]\n",
"\n",
"first_circle_Jan24 = circles_Jan24[0]\n",
"\n",
"dropsonde_ids = segments_by_segment_id[first_circle_Jan24][\"dropsondes\"][\"GOOD\"]"
]
},
{
"cell_type": "markdown",
"id": "bde5f87f-503d-48f2-9cfc-8a4a8c9010a9",
"metadata": {},
"source": [
"Load dropsonde dataset and select first circle of January 24, 2020:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5f08a63c-b9e8-4d9e-b48c-ae27983a3920",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"ds = cat.dropsondes.JOANNE.level3.to_dask()\n",
"\n",
"# Select dropsondes from Jan 24 2020\n",
"mask_sondes_first_circle_Jan24 = reduce(lambda a, b: a | b, [ds.sonde_id==d for d in dropsonde_ids])\n",
"mask_sondes_third_circle_Jan24 = reduce(lambda a, b: a | b, [ds.sonde_id==d for d in dropsonde_ids])\n",
"\n",
"ds_sondes_first_circle_Jan24 = ds.isel(sonde_id=mask_sondes_first_circle_Jan24)\n",
"ds_sondes_third_circle_Jan24 = ds.isel(sonde_id=mask_sondes_third_circle_Jan24)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "14d71026-054c-410f-8723-b44adcf31f0b",
"metadata": {},
"outputs": [],
"source": [
"ds_sondes_first_circle_Jan24"
]
},
{
"cell_type": "markdown",
"id": "f01f4463-b18a-4562-ac57-0278a5d27a19",
"metadata": {},
"source": [
"Access satellite images:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6de0f717-bd26-4eec-8eba-6f43ee98a57a",
"metadata": {},
"outputs": [],
"source": [
"satellite_image = ql.get_satellite_data(ds_flight=ds_sondes_first_circle_Jan24,\n",
" satellite_name=\"goes16\", channel = 13, product=\"ABI-L2-CMIPF\")#,\n",
" #extent = (-62,-48,10,30))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5118c746-9a84-4323-b3bc-c1b3c2c61793",
"metadata": {},
"outputs": [],
"source": [
"satellite_image"
]
},
{
"cell_type": "markdown",
"id": "b5834ca1-2c9f-47c7-bf7b-0c8ce62eb897",
"metadata": {},
"source": [
"## Plot dropsonde launch locations on a map (over a GOES-16 image)\n",
"\n",
"By default the satellite image will be taken at the average launch time from all dropsondes in the plot. By default the colormap is chosen to show the flight altitude, but it can be any variable with dimensions (`sonde_id`)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "652d22a6-0ff9-45f8-8b69-8608f18d7ae5",
"metadata": {},
"outputs": [],
"source": [
"ql.launch_locations_map(ds_flight=ds_sondes_first_circle_Jan24, save_filepath=\"/home/m/m300931/\", \n",
" satellite_data=satellite_image)\n",
" #extent = (-62,-48,10,30))"
]
},
{
"cell_type": "markdown",
"id": "61c0e563-6411-41c1-a21e-d4d23c064537",
"metadata": {},
"source": [
"## Plot latitude-time quantities\n",
"\n",
"By default the colormap is chosen to show the flight altitude, but it can be any variable with dimensions (`sonde_id`)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5dc93114-76fc-4ce6-88b9-dab6944428f6",
"metadata": {},
"outputs": [],
"source": [
"ql.plot_lat_time(ds_flight=ds_sondes_first_circle_Jan24, save_filepath=\"/home/m/m300931/\")"
]
},
{
"cell_type": "markdown",
"id": "e7005a0b-8603-4a8e-8306-af5933ce2a5a",
"metadata": {},
"source": [
"## Plot vertical profiles\n",
"The variables and number of plots can be adjusted by the user. By default the quicklook shows temperature, potential temperature, relative humidity, and wind speed."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0d1315af-7d6e-499e-a1ce-2cda46562724",
"metadata": {},
"outputs": [],
"source": [
"ql.plot_profiles(ds_flight=ds_sondes_first_circle_Jan24, save_filepath=\"/home/m/m300931/\")"
]
},
{
"cell_type": "markdown",
"id": "c54961a5-873d-4091-b798-d72e42d06a45",
"metadata": {},
"source": [
"## Plot dropsonde drift"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "805d161e-72bd-4596-948d-75842b6df1e2",
"metadata": {},
"outputs": [],
"source": [
"ql.drift_plots(ds_flight=ds_sondes_first_circle_Jan24, save_filepath=\"/home/m/m300931/\")"
]
},
{
"cell_type": "markdown",
"id": "31d1e2b6-0bb0-4b03-b94f-cd0619b7abe7",
"metadata": {},
"source": [
"## Saving plots in one pdf"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4b542d28-3a83-4801-b767-316959ede93d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "HALO-DROPS",
"language": "python",
"name": "my-kernel"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
19 changes: 19 additions & 0 deletions src/halodrops/api/plotting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from halodrops.plotting import quicklooks as ql


# Access satellite data
satellite_image = ql.get_satellite_data()

# Plot launch locations over satellite images
ql.launch_locations_map()

# Plot longitude/time
ql.plot_lat_time()

# Plot vertical profiles
ql.plot_profiles()

# Plot dropsonde drift
ql.drift_plots()

# Output all quicklooks into a PDF
Loading