-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathhtml.json
More file actions
21 lines (21 loc) · 54.1 KB
/
Copy pathhtml.json
File metadata and controls
21 lines (21 loc) · 54.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
"hash": "79c8ff972722ef9b710ee2232c87cf6a",
"result": {
"engine": "knitr",
"markdown": "---\ndate: last-modified\ntitle: Demonstration for working with TEMPO data in R\n---\n\n\n\n## Overview\n\nThis notebook retrieves TEMPO data, inspects characteristics of the data such as array shapes and quality flags, and then creates a visualization of total column nitrogen dioxide concentrations.\n\nThis notebook is a fork of the [original Python notebook](https://nasa.github.io/ASDC_Data_and_User_Services/TEMPO/how_to_examine_TEMPO_data_using_earthaccess.html) from the [ASDC Data and User Services Tutorials Cookbook](https://nasa.github.io/ASDC_Data_and_User_Services/). \n\n## Dataset Information\n\nThis notebook uses data from the [Tropospheric Emissions: Monitoring of Pollution (TEMPO)](https://asdc.larc.nasa.gov/project/TEMPO) instrument.\n\n## Prerequisites\n\nA free(!) account at https://www.earthdata.nasa.gov/ is needed to login and download the appropriate files.\n\nThis notebook was last tested using R Version 4.5.1 and uses these packages:\n\n- [earthadatalogin](https://boettiger-lab.github.io/earthadatalogin/)\n- [rstac](https://brazil-data-cube.github.io/rstac/)\n- [terra](https://rspatial.org/terra/)\n\n### Notebook Author / Affiliation\n\nAlexander Radkevich / Atmospheric Science Data Center (ASDC) - original Python notebook\nAndy Teucher (Openscapes) - R adaptation\n\n# 1. Setup\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# Core packages for data access and manipulation\nlibrary(earthdatalogin) # Authentication with NASA Earthdata and data access\nlibrary(rstac) # Search STAC catalogs\n```\n\n::: {.cell-output .cell-output-stderr}\n\n```\n\nAttaching package: 'rstac'\n```\n\n\n:::\n\n::: {.cell-output .cell-output-stderr}\n\n```\nThe following object is masked from 'package:earthdatalogin':\n\n collections_fetch\n```\n\n\n:::\n\n```{.r .cell-code}\nlibrary(terra) # Read, manipulate, and plot raster data\n```\n\n::: {.cell-output .cell-output-stderr}\n\n```\nterra 1.8.80\n```\n\n\n:::\n\n```{.r .cell-code}\n# Helper packages\nlibrary(purrr) # Functional programming tools / list manipulation\nlibrary(mirai) # Parallel downloads\nlibrary(stringr) # String manipulation\nlibrary(tigris) # State boundaries for plotting\n```\n\n::: {.cell-output .cell-output-stderr}\n\n```\nTo enable caching of data, set `options(tigris_use_cache = TRUE)`\nin your R script or .Rprofile.\n```\n\n\n:::\n\n::: {.cell-output .cell-output-stderr}\n\n```\n\nAttaching package: 'tigris'\n```\n\n\n:::\n\n::: {.cell-output .cell-output-stderr}\n\n```\nThe following object is masked from 'package:terra':\n\n blocks\n```\n\n\n:::\n:::\n\n\n# 2. Establish access to EarthData - Log in\n\nIt is best practice to store your EarthData credentials in environment variables `EARTHDATA_USER` and `EARTHDATA_PASSWORD` prior to running `earthdatalogin::edl_netrc()`. You can open your `.Renviron` file for editing using `usethis::edit_r_environ()`. Then add the following lines, replacing `your_username` and `your_password` with your actual EarthData credentials: \n\n```\nEARTHDATA_USER=your_username\nEARTHDATA_PASSWORD=your_password\n```\n\nIf credentials are not already stored, `earthdatalogin::edl_netrc()` will use a default username and password.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nedl_netrc()\n```\n:::\n\n\n# 3. Search for TEMPO granules\n\nFirst, we specify the data collection by name, a Point of Interest (POI), and a temporal range.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nshort_name <- \"TEMPO_NO2_L3\" # collection name to search for in the EarthData\nversion <- \"V03\"\n\n# Point of interest: NASA Langley Research Center, HamptonVA, USA\n# latitude 37.1036 deg, longitude -76.3868 deg\n# POI_lat <- 37.1036\n# POI_lon <- -76.3868\n\n# generic location, somewhere in the middle of the USA\nPOI_lat <- 38.0\nPOI_lon <- -96.0\ndate_start <- \"2024-09-01T00:00:00Z\"\ndate_end <- \"2024-09-01T23:59:59Z\"\n```\n:::\n\n\nNow we search for nitrogen dioxide ($NO_2$) data granules from TEMPO.\n\n\n::: {.cell}\n\n```{.r .cell-code}\ndlat <- 5.0 # deg\ndlon <- 6.0 # deg\n\nbbox_results <- earthdatalogin::edl_search(\n short_name = short_name,\n version = version,\n temporal = c(date_start, date_end),\n bounding_box = c(\n POI_lon - dlon,\n POI_lat - dlat,\n POI_lon + dlon,\n POI_lat + dlat\n ), # search by bounding box\n parse_results = FALSE\n)\n\nlength(bbox_results)\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n[1] 18\n```\n\n\n:::\n:::\n\n\n# 4. Examine and download file results\n\n## What does a result look like?\n\nThere is a lot of metadata associated with each result. We will use `purrr::discard_at()` to remove the `polygons` and `links` elements from the first result for easier viewing.\n\n\n::: {.cell}\n\n```{.r .cell-code}\npurrr::discard_at(bbox_results[[1]], c(\"polygons\", \"links\"))\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n$producer_granule_id\n[1] \"TEMPO_NO2_L3_V03_20240831T235844Z_S016.nc\"\n\n$time_start\n[1] \"2024-08-31T23:58:44.000Z\"\n\n$updated\n[1] \"2024-09-01T10:06:16.770Z\"\n\n$dataset_id\n[1] \"TEMPO gridded NO2 tropospheric and stratospheric columns V03 (PROVISIONAL)\"\n\n$data_center\n[1] \"LARC_CLOUD\"\n\n$title\n[1] \"TEMPO_NO2_L3_V03_20240831T235844Z_S016.nc\"\n\n$coordinate_system\n[1] \"CARTESIAN\"\n\n$day_night_flag\n[1] \"UNSPECIFIED\"\n\n$time_end\n[1] \"2024-09-01T00:38:30.000Z\"\n\n$id\n[1] \"G3222677814-LARC_CLOUD\"\n\n$original_format\n[1] \"UMM_JSON\"\n\n$granule_size\n[1] \"529.1977777481079\"\n\n$browse_flag\n[1] TRUE\n\n$collection_concept_id\n[1] \"C2930763263-LARC_CLOUD\"\n\n$online_access_flag\n[1] TRUE\n```\n\n\n:::\n:::\n\n\n## Examining file names\n\nLet's examine the file names present in the results object.\n\n\n::: {.cell}\n\n```{.r .cell-code}\ntempo_urls <- edl_extract_urls(bbox_results)\ntempo_urls\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n [1] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.08.31/TEMPO_NO2_L3_V03_20240831T235844Z_S016.nc\"\n [2] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T003849Z_S017.nc\"\n [3] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T105755Z_S001.nc\"\n [4] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T113800Z_S002.nc\"\n [5] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T121805Z_S003.nc\"\n [6] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T125810Z_S004.nc\"\n [7] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T133815Z_S005.nc\"\n [8] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T143815Z_S006.nc\"\n [9] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\"\n[10] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T163815Z_S008.nc\"\n[11] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T173815Z_S009.nc\"\n[12] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T183815Z_S010.nc\"\n[13] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T193815Z_S011.nc\"\n[14] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T203815Z_S012.nc\"\n[15] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T213815Z_S013.nc\"\n[16] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T223815Z_S014.nc\"\n[17] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T231820Z_S015.nc\"\n[18] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T235825Z_S016.nc\"\n```\n\n\n:::\n:::\n\n\n## Downloading granules\n\nHere we'll download two of the files. We can use purrr's `in_parallel()` function to download multiple files in parallel. We use `mirai::daemons()` to set the number of parallel workers.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nmirai::daemons(3)\n\nfiles <- purrr::map_chr(\n tempo_urls[9:11],\n in_parallel(\\(x) earthdatalogin::edl_download(x))\n)\n\n# Reset the number of parallel workers to 0\nmirai::daemons(0)\n```\n:::\n\n\n# 5. Reading and inspecting the data\n\nWe downloaded the data in the previous step, however we can avoid downloading the files manually and download them only as-needed by specifying what we want with `terra::rast()`.\n\nFirst, let's look at the metadata. We can get the metadata in different ways, using `terra::describe()` to get file-level metadata and metadata about the subdatasets within. We prepend the URL with `/vsicurl/` to read the file remotely.\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# The netCDF driver does not work on non-Linux systems when reading via `/vis`,\n# So we unload it here to force GDAL to use the HDF5 driver instead.\nif (tolower(Sys.info()[[\"sysname\"]]) != \"linux\") {\n unloadGDALdrivers(\"netCDF\")\n}\n```\n:::\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nnc_file <- tempo_urls[9]\nnc_file\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n[1] \"https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\"\n```\n\n\n:::\n\n```{.r .cell-code}\nterra_meta_file <- terra::describe(\n paste0(\"/vsicurl/\", nc_file),\n sds = FALSE,\n meta = TRUE\n)\n\n# The data comes as a character vector with name-value pairs separated by '='.\n# We can turn it into a data frame for easier viewing.\ndata.frame(\n Name = stringr::str_split_i(terra_meta_file, \"=\", 1),\n Value = stringr::str_split_i(terra_meta_file, \"=\", 2)\n) |>\n DT::datatable(caption = \"File-level metadata\")\n```\n\n::: {.cell-output-display}\n\n```{=html}\n<div class=\"datatables html-widget html-fill-item\" id=\"htmlwidget-04666526e0bcd539944a\" style=\"width:100%;height:auto;\"></div>\n<script type=\"application/json\" data-for=\"htmlwidget-04666526e0bcd539944a\">{\"x\":{\"filter\":\"none\",\"vertical\":false,\"caption\":\"<caption>File-level metadata<\\/caption>\",\"data\":[[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\",\"12\",\"13\",\"14\",\"15\",\"16\",\"17\",\"18\",\"19\",\"20\",\"21\",\"22\",\"23\",\"24\",\"25\",\"26\",\"27\",\"28\",\"29\",\"30\",\"31\",\"32\",\"33\",\"34\",\"35\",\"36\",\"37\",\"38\",\"39\",\"40\",\"41\",\"42\",\"43\",\"44\",\"45\",\"46\",\"47\",\"48\",\"49\",\"50\",\"51\",\"52\",\"53\",\"54\",\"55\",\"56\",\"57\",\"58\",\"59\",\"60\",\"61\",\"62\",\"63\",\"64\",\"65\",\"66\",\"67\",\"68\",\"69\",\"70\",\"71\",\"72\",\"73\",\"74\",\"75\",\"76\",\"77\",\"78\",\"79\",\"80\",\"81\",\"82\",\"83\",\"84\",\"85\",\"86\",\"87\",\"88\",\"89\",\"90\",\"91\",\"92\",\"93\",\"94\",\"95\",\"96\",\"97\",\"98\",\"99\",\"100\",\"101\",\"102\",\"103\",\"104\",\"105\",\"106\",\"107\",\"108\",\"109\",\"110\",\"111\",\"112\",\"113\",\"114\",\"115\",\"116\",\"117\",\"118\",\"119\",\"120\",\"121\",\"122\",\"123\",\"124\",\"125\",\"126\",\"127\",\"128\",\"129\",\"130\",\"131\",\"132\",\"133\",\"134\",\"135\",\"136\",\"137\",\"138\",\"139\",\"140\",\"141\",\"142\",\"143\",\"144\",\"145\",\"146\",\"147\",\"148\",\"149\",\"150\",\"151\",\"152\",\"153\",\"154\",\"155\",\"156\",\"157\",\"158\",\"159\",\"160\",\"161\",\"162\",\"163\",\"164\",\"165\",\"166\",\"167\",\"168\",\"169\",\"170\",\"171\",\"172\",\"173\",\"174\",\"175\",\"176\",\"177\",\"178\",\"179\",\"180\",\"181\",\"182\",\"183\",\"184\",\"185\",\"186\",\"187\",\"188\",\"189\",\"190\",\"191\",\"192\",\"193\",\"194\",\"195\",\"196\",\"197\",\"198\",\"199\",\"200\",\"201\",\"202\",\"203\",\"204\",\"205\",\"206\",\"207\",\"208\",\"209\",\"210\",\"211\",\"212\",\"213\",\"214\",\"215\",\"216\",\"217\",\"218\",\"219\",\"220\",\"221\",\"222\",\"223\",\"224\",\"225\",\"226\",\"227\",\"228\",\"229\",\"230\",\"231\",\"232\",\"233\",\"234\",\"235\",\"236\",\"237\",\"238\",\"239\"],[\"begin_date\",\"begin_time\",\"collection_shortname\",\"collection_version\",\"Conventions\",\"coremetadata\",\"creator_url\",\"day_of_year\",\"end_date\",\"end_time\",\"geolocation_relative_azimuth_angle_coordinates\",\"geolocation_relative_azimuth_angle_long_name\",\"geolocation_relative_azimuth_angle_units\",\"geolocation_relative_azimuth_angle_valid_max\",\"geolocation_relative_azimuth_angle_valid_min\",\"geolocation_relative_azimuth_angle__FillValue\",\"geolocation_solar_zenith_angle_coordinates\",\"geolocation_solar_zenith_angle_long_name\",\"geolocation_solar_zenith_angle_units\",\"geolocation_solar_zenith_angle_valid_max\",\"geolocation_solar_zenith_angle_valid_min\",\"geolocation_solar_zenith_angle__FillValue\",\"geolocation_viewing_zenith_angle_coordinates\",\"geolocation_viewing_zenith_angle_long_name\",\"geolocation_viewing_zenith_angle_units\",\"geolocation_viewing_zenith_angle_valid_max\",\"geolocation_viewing_zenith_angle_valid_min\",\"geolocation_viewing_zenith_angle__FillValue\",\"geospatial_bounds\",\"geospatial_bounds_crs\",\"geospatial_lat_max\",\"geospatial_lat_min\",\"geospatial_lon_max\",\"geospatial_lon_min\",\"history\",\"input_files\",\"institution\",\"keywords\",\"latitude_CLASS\",\"latitude_comment\",\"latitude_long_name\",\"latitude_NAME\",\"latitude_REFERENCE_LIST\",\"latitude_standard_name\",\"latitude_units\",\"latitude_valid_max\",\"latitude_valid_min\",\"latitude__Netcdf4Dimid\",\"local_granule_id\",\"longitude_CLASS\",\"longitude_comment\",\"longitude_long_name\",\"longitude_NAME\",\"longitude_REFERENCE_LIST\",\"longitude_standard_name\",\"longitude_units\",\"longitude_valid_max\",\"longitude_valid_min\",\"longitude__Netcdf4Dimid\",\"pge_version\",\"platform\",\"processing_level\",\"processing_version\",\"production_date_time\",\"product_main_data_quality_flag_coordinates\",\"product_main_data_quality_flag_flag_meanings\",\"product_main_data_quality_flag_flag_values\",\"product_main_data_quality_flag_long_name\",\"product_main_data_quality_flag_valid_max\",\"product_main_data_quality_flag_valid_min\",\"product_main_data_quality_flag__FillValue\",\"product_type\",\"product_vertical_column_stratosphere_coordinates\",\"product_vertical_column_stratosphere_long_name\",\"product_vertical_column_stratosphere_units\",\"product_vertical_column_stratosphere__FillValue\",\"product_vertical_column_troposphere_coordinates\",\"product_vertical_column_troposphere_long_name\",\"product_vertical_column_troposphere_uncertainty_coordinates\",\"product_vertical_column_troposphere_uncertainty_long_name\",\"product_vertical_column_troposphere_uncertainty_units\",\"product_vertical_column_troposphere_uncertainty__FillValue\",\"product_vertical_column_troposphere_units\",\"product_vertical_column_troposphere__FillValue\",\"project\",\"qa_statistics_max_vertical_column_stratosphere_sample_comment\",\"qa_statistics_max_vertical_column_stratosphere_sample_coordinates\",\"qa_statistics_max_vertical_column_stratosphere_sample_long_name\",\"qa_statistics_max_vertical_column_stratosphere_sample_units\",\"qa_statistics_max_vertical_column_stratosphere_sample__FillValue\",\"qa_statistics_max_vertical_column_total_sample_comment\",\"qa_statistics_max_vertical_column_total_sample_coordinates\",\"qa_statistics_max_vertical_column_total_sample_long_name\",\"qa_statistics_max_vertical_column_total_sample_units\",\"qa_statistics_max_vertical_column_total_sample__FillValue\",\"qa_statistics_max_vertical_column_troposphere_sample_comment\",\"qa_statistics_max_vertical_column_troposphere_sample_coordinates\",\"qa_statistics_max_vertical_column_troposphere_sample_long_name\",\"qa_statistics_max_vertical_column_troposphere_sample_units\",\"qa_statistics_max_vertical_column_troposphere_sample__FillValue\",\"qa_statistics_max_vertical_column_troposphere_uncertainty_sample_comment\",\"qa_statistics_max_vertical_column_troposphere_uncertainty_sample_coordinates\",\"qa_statistics_max_vertical_column_troposphere_uncertainty_sample_long_name\",\"qa_statistics_max_vertical_column_troposphere_uncertainty_sample_units\",\"qa_statistics_max_vertical_column_troposphere_uncertainty_sample__FillValue\",\"qa_statistics_min_vertical_column_stratosphere_sample_comment\",\"qa_statistics_min_vertical_column_stratosphere_sample_coordinates\",\"qa_statistics_min_vertical_column_stratosphere_sample_long_name\",\"qa_statistics_min_vertical_column_stratosphere_sample_units\",\"qa_statistics_min_vertical_column_stratosphere_sample__FillValue\",\"qa_statistics_min_vertical_column_total_sample_comment\",\"qa_statistics_min_vertical_column_total_sample_coordinates\",\"qa_statistics_min_vertical_column_total_sample_long_name\",\"qa_statistics_min_vertical_column_total_sample_units\",\"qa_statistics_min_vertical_column_total_sample__FillValue\",\"qa_statistics_min_vertical_column_troposphere_sample_comment\",\"qa_statistics_min_vertical_column_troposphere_sample_coordinates\",\"qa_statistics_min_vertical_column_troposphere_sample_long_name\",\"qa_statistics_min_vertical_column_troposphere_sample_units\",\"qa_statistics_min_vertical_column_troposphere_sample__FillValue\",\"qa_statistics_min_vertical_column_troposphere_uncertainty_sample_comment\",\"qa_statistics_min_vertical_column_troposphere_uncertainty_sample_coordinates\",\"qa_statistics_min_vertical_column_troposphere_uncertainty_sample_long_name\",\"qa_statistics_min_vertical_column_troposphere_uncertainty_sample_units\",\"qa_statistics_min_vertical_column_troposphere_uncertainty_sample__FillValue\",\"qa_statistics_num_vertical_column_stratosphere_samples_comment\",\"qa_statistics_num_vertical_column_stratosphere_samples__FillValue\",\"qa_statistics_num_vertical_column_total_samples_comment\",\"qa_statistics_num_vertical_column_total_samples__FillValue\",\"qa_statistics_num_vertical_column_troposphere_samples_comment\",\"qa_statistics_num_vertical_column_troposphere_samples__FillValue\",\"qa_statistics_num_vertical_column_troposphere_uncertainty_samples_comment\",\"qa_statistics_num_vertical_column_troposphere_uncertainty_samples__FillValue\",\"scan_num\",\"sdpc_version\",\"shortname\",\"source\",\"summary\",\"support_data_albedo_coordinates\",\"support_data_albedo_long_name\",\"support_data_albedo_valid_max\",\"support_data_albedo_valid_min\",\"support_data_albedo__FillValue\",\"support_data_amf_cloud_fraction_comment\",\"support_data_amf_cloud_fraction_coordinates\",\"support_data_amf_cloud_fraction_long_name\",\"support_data_amf_cloud_fraction_valid_max\",\"support_data_amf_cloud_fraction_valid_min\",\"support_data_amf_cloud_fraction__FillValue\",\"support_data_amf_cloud_pressure_comment\",\"support_data_amf_cloud_pressure_coordinates\",\"support_data_amf_cloud_pressure_long_name\",\"support_data_amf_cloud_pressure_units\",\"support_data_amf_cloud_pressure_valid_max\",\"support_data_amf_cloud_pressure_valid_min\",\"support_data_amf_cloud_pressure__FillValue\",\"support_data_amf_stratosphere_coordinates\",\"support_data_amf_stratosphere_long_name\",\"support_data_amf_stratosphere_valid_min\",\"support_data_amf_stratosphere__FillValue\",\"support_data_amf_total_comment\",\"support_data_amf_total_coordinates\",\"support_data_amf_total_long_name\",\"support_data_amf_total_valid_min\",\"support_data_amf_total__FillValue\",\"support_data_amf_troposphere_coordinates\",\"support_data_amf_troposphere_long_name\",\"support_data_amf_troposphere_valid_min\",\"support_data_amf_troposphere__FillValue\",\"support_data_eff_cloud_fraction_comment\",\"support_data_eff_cloud_fraction_coordinates\",\"support_data_eff_cloud_fraction_long_name\",\"support_data_eff_cloud_fraction_valid_max\",\"support_data_eff_cloud_fraction_valid_min\",\"support_data_eff_cloud_fraction__FillValue\",\"support_data_fitted_slant_column_coordinates\",\"support_data_fitted_slant_column_long_name\",\"support_data_fitted_slant_column_uncertainty_coordinates\",\"support_data_fitted_slant_column_uncertainty_long_name\",\"support_data_fitted_slant_column_uncertainty_units\",\"support_data_fitted_slant_column_uncertainty__FillValue\",\"support_data_fitted_slant_column_units\",\"support_data_fitted_slant_column__FillValue\",\"support_data_snow_ice_fraction_coordinates\",\"support_data_snow_ice_fraction_long_name\",\"support_data_snow_ice_fraction_valid_max\",\"support_data_snow_ice_fraction_valid_min\",\"support_data_snow_ice_fraction__FillValue\",\"support_data_surface_pressure_coordinates\",\"support_data_surface_pressure_Eta_A\",\"support_data_surface_pressure_Eta_B\",\"support_data_surface_pressure_long_name\",\"support_data_surface_pressure_units\",\"support_data_surface_pressure_valid_max\",\"support_data_surface_pressure_valid_min\",\"support_data_surface_pressure__FillValue\",\"support_data_terrain_height_coordinates\",\"support_data_terrain_height_long_name\",\"support_data_terrain_height_units\",\"support_data_terrain_height_valid_max\",\"support_data_terrain_height_valid_min\",\"support_data_terrain_height__FillValue\",\"support_data_tropopause_pressure_coordinates\",\"support_data_tropopause_pressure_long_name\",\"support_data_tropopause_pressure_units\",\"support_data_tropopause_pressure_valid_max\",\"support_data_tropopause_pressure_valid_min\",\"support_data_tropopause_pressure__FillValue\",\"support_data_vertical_column_total_comment\",\"support_data_vertical_column_total_coordinates\",\"support_data_vertical_column_total_long_name\",\"support_data_vertical_column_total_uncertainty_coordinates\",\"support_data_vertical_column_total_uncertainty_long_name\",\"support_data_vertical_column_total_uncertainty_units\",\"support_data_vertical_column_total_uncertainty__FillValue\",\"support_data_vertical_column_total_units\",\"support_data_vertical_column_total__FillValue\",\"time_calendar\",\"time_CLASS\",\"time_coverage_end\",\"time_coverage_end_since_epoch\",\"time_coverage_start\",\"time_coverage_start_since_epoch\",\"time_long_name\",\"time_NAME\",\"time_reference\",\"time_REFERENCE_LIST\",\"time_standard_name\",\"time_units\",\"time__Netcdf4Dimid\",\"title\",\"version_id\",\"weight_comment\",\"weight_coordinates\",\"weight_long_name\",\"weight_units\",\"weight__FillValue\",\"weight__Netcdf4Dimid\",\"_NCProperties\"],[\"2024-09-01\",\"15:38:15\",\"TEMPO_NO2_L3\",\"1\",\"CF-1.6, ACDD-1.3\",\"\\nGROUP \",\"http://tempo.si.edu\",\"245\",\"2024-09-01\",\"16:37:56\",\"time longitude latitude\",\"relative azimuth angle at pixel center\",\"degrees\",\"180\",\"-180\",\"-1e+30\",\"time longitude latitude\",\"solar zenith angle at pixel center\",\"degrees\",\"90\",\"0\",\"-1e+30\",\"time longitude latitude\",\"viewing zenith angle at pixel center\",\"degrees\",\"90\",\"0\",\"-1e+30\",\"POLYGON((57.1800 -163.6600,56.7800 -163.0200,56.0000 -158.7200,54.7200 -153.6800,53.5000 -149.9800,52.0200 -146.3400,50.4000 -143.0600,48.4200 -139.7400,46.2000 -136.6600,43.6400 -133.7200,41.0200 -131.2200,38.3800 -129.1000,35.4200 -127.1000,32.5400 -125.4600,29.1800 -123.8600,25.5400 -122.4400,21.6400 -121.2200,17.5400 -120.2200,17.3000 -108.8200,17.1800 -94.0800,17.2400 -78.7800,17.4600 -65.2600,21.3000 -64.4200,25.2000 -63.3600,29.0800 -62.0600,32.6600 -60.6000,35.7400 -59.1000,38.9200 -57.2600,42.1400 -55.0200,44.5600 -53.0200,47.4400 -50.1800,50.1400 -46.9200,52.4200 -43.5400,54.6800 -39.3800,56.5800 -34.9400,58.0200 -30.6600,59.2600 -25.9000,60.1600 -21.1600,60.3800 -20.6000,60.4600 -20.0400,61.2000 -20.0400,61.1600 -20.2800,62.0600 -20.3000,62.0000 -20.7000,62.2000 -20.8800,62.1800 -21.0400,62.9600 -21.0600,62.8800 -21.5800,63.7600 -21.6800,63.6400 -22.5600,63.7800 -22.6400,62.2400 -33.3600,60.7800 -44.2800,59.8000 -53.0800,59.1000 -60.0200,58.6000 -65.8000,58.0400 -74.5800,57.7600 -81.5000,57.6200 -89.0800,57.6600 -96.9200,57.9000 -104.7000,58.3400 -112.7600,58.9800 -121.1600,59.9000 -130.6400,60.7600 -137.9400,60.9200 -138.8600,60.8800 -139.0200,61.0800 -140.1600,61.0200 -140.2200,61.1800 -140.9000,61.2400 -141.3800,61.1800 -141.4200,61.3400 -142.1400,62.1800 -148.8000,63.4800 -157.6600,63.5400 -158.9600,63.7400 -160.3400,62.8800 -160.5200,63.0000 -161.4600,61.6200 -161.5000,61.6800 -162.0400,60.4200 -162.2000,60.5400 -163.0800,59.4600 -163.1000,59.4800 -163.3000,57.9600 -163.4000,57.9800 -163.6600,57.1800 -163.6600))\",\"EPSG:4326\",\"63.779999\",\"17.18\",\"-20.040009\",\"-163.66\",\"2024-09-01T22:40:30Z: L2_regrid -v /tempo/nas0/sdpc/liveroot/temposdpc/ops4/etc/l3.cfg\\n\",\"TEMPO_NO2_L2_V03_20240901T153815Z_S007G01.nc TEMPO_NO2_L2_V03_20240901T154455Z_S007G02.nc TEMPO_NO2_L2_V03_20240901T155135Z_S007G03.nc TEMPO_NO2_L2_V03_20240901T155813Z_S007G04.nc TEMPO_NO2_L2_V03_20240901T160450Z_S007G05.nc TEMPO_NO2_L2_V03_20240901T161127Z_S007G06.nc TEMPO_NO2_L2_V03_20240901T161805Z_S007G07.nc TEMPO_NO2_L2_V03_20240901T162442Z_S007G08.nc TEMPO_NO2_L2_V03_20240901T163119Z_S007G09.nc\",\"Smithsonian Astrophysical Observatory\",\"EARTH SCIENCE>ATMOSPHERE>AIR QUALITY>NITROGEN OXIDES, EARTH SCIENCE>ATMOSPHERE>ATMOSPHERIC CHEMISTRY>NITROGEN COMPOUNDS>NITROGEN DIOXIDE\",\"DIMENSION_SCALE\",\"latitude at grid box center\",\"latitude\",\"latitude\",\"\",\"latitude\",\"degrees_north\",\"90\",\"-90\",\"1\",\"TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\",\"DIMENSION_SCALE\",\"longitude at grid box center\",\"longitude\",\"longitude\",\"\",\"longitude\",\"degrees_east\",\"180\",\"-180\",\"0\",\"1.0.0\",\"Intelsat 40e\",\"3\",\"3\",\"2024-09-01T22:40:31Z\",\"time longitude latitude\",\"normal suspicious bad\",\"0 1 2\",\"main data quality flag\",\"2\",\"0\",\"-9999\",\"NO2\",\"time longitude latitude\",\"stratosphere nitrogen dioxide vertical column\",\"molecules/cm^2\",\"-1e+30\",\"time longitude latitude\",\"troposphere nitrogen dioxide vertical column\",\"time longitude latitude\",\"troposphere nitrogen dioxide vertical column uncertainty\",\"molecules/cm^2\",\"-1e+30\",\"molecules/cm^2\",\"-1e+30\",\"TEMPO\",\"Largest Level 2 pixel values contributing to the area-weighted Level 3 pixel value\",\"time longitude latitude\",\"stratosphere nitrogen dioxide vertical column\",\"molecules/cm^2\",\"-1e+30\",\"Largest Level 2 pixel values contributing to the area-weighted Level 3 pixel value\",\"time longitude latitude\",\"nitrogen dioxide vertical column\",\"molecules/cm^2\",\"-1e+30\",\"Largest Level 2 pixel values contributing to the area-weighted Level 3 pixel value\",\"time longitude latitude\",\"troposphere nitrogen dioxide vertical column\",\"molecules/cm^2\",\"-1e+30\",\"Largest Level 2 pixel values contributing to the area-weighted Level 3 pixel value\",\"time longitude latitude\",\"troposphere nitrogen dioxide vertical column uncertainty\",\"molecules/cm^2\",\"-1e+30\",\"Smallest Level 2 pixel value contributing to the area-weighted Level 3 pixel value\",\"time longitude latitude\",\"stratosphere nitrogen dioxide vertical column\",\"molecules/cm^2\",\"-1e+30\",\"Smallest Level 2 pixel value contributing to the area-weighted Level 3 pixel value\",\"time longitude latitude\",\"nitrogen dioxide vertical column\",\"molecules/cm^2\",\"-1e+30\",\"Smallest Level 2 pixel value contributing to the area-weighted Level 3 pixel value\",\"time longitude latitude\",\"troposphere nitrogen dioxide vertical column\",\"molecules/cm^2\",\"-1e+30\",\"Smallest Level 2 pixel value contributing to the area-weighted Level 3 pixel value\",\"time longitude latitude\",\"troposphere nitrogen dioxide vertical column uncertainty\",\"molecules/cm^2\",\"-1e+30\",\"Number of Level 2 pixel values contributing to the area-weighted Level 3 pixel value\",\"-1\",\"Number of Level 2 pixel values contributing to the area-weighted Level 3 pixel value\",\"-1\",\"Number of Level 2 pixel values contributing to the area-weighted Level 3 pixel value\",\"-1\",\"Number of Level 2 pixel values contributing to the area-weighted Level 3 pixel value\",\"-1\",\"7\",\"TEMPO_SDPC_v4.4.2\",\"TEMPO_NO2_L3\",\"UV-VIS hyperspectral imaging\",\"Nitrogen dioxide Level 3 files provide trace gas information on a regular grid covering the TEMPO field of regard for nominal TEMPO observations. Level 3 files are derived by combining information from all Level 2 files constituting a TEMPO East-West scan cycle. The files are provided in netCDF4 format, and contain information on tropospheric, stratospheric and total nitrogen dioxide vertical columns, ancillary data used in air mass factor and stratospheric/tropospheric separation calculations, and retrieval quality flags. The re-gridding algorithm uses an area-weighted approach.\",\"time longitude latitude\",\"surface albedo\",\"1\",\"0\",\"-1e+30\",\"cloud radiance fraction for AMF computation\",\"time longitude latitude\",\"cloud fraction\",\"1\",\"0\",\"-1e+30\",\"cloud pressure for AMF computation\",\"time longitude latitude\",\"cloud pressure\",\"hPa\",\"1200\",\"0\",\"-1e+30\",\"time longitude latitude\",\"nitrogen dioxide stratospheric air mass factor\",\"0\",\"-1e+30\",\"total nitrogen dioxide air mass factor (AMF) calculated from surface to top of atmosphere\",\"time longitude latitude\",\"nitrogen dioxide air mass factor\",\"0\",\"-1e+30\",\"time longitude latitude\",\"nitrogen dioxide tropospheric air mass factor\",\"0\",\"-1e+30\",\"effective cloud fraction from cloud retrieval\",\"time longitude latitude\",\"effective cloud fraction\",\"1\",\"0\",\"-1e+30\",\"time longitude latitude\",\"nitrogen dioxide fitted slant column\",\"time longitude latitude\",\"nitrogen dioxide fitted slant column uncertainty\",\"molecules/cm^2\",\"-1e+30\",\"molecules/cm^2\",\"-1e+30\",\"time longitude latitude\",\"fraction of pixel area covered by snow and/or ice\",\"1\",\"0\",\"-1e+30\",\"time longitude latitude\",\"0 0.048048262 6.5937519 13.1348 19.61311 26.09201 32.570808 38.98201 45.339008 51.69611 58.053211 64.36264 70.621979 78.834221 89.099922 99.365211 109.1817 118.9586 128.69591 142.91 156.25999 169.60899 181.619 193.097 203.259 212.14999 218.776 223.89799 224.36301 216.86501 201.192 176.92999 150.39301 127.837 108.663 92.365723 78.512306 66.603409 56.387909 47.643909 40.175411 33.810009 28.367809 23.73041 19.791599 16.4571 13.6434 11.2769 9.292942 7.6198421 6.2168012 5.0468011 4.076571 3.2764311 2.6202109 2.08497 1.65079 1.30051 1.0194401 0.79513413 0.61677909 0.47580609 0.36504111 0.2785261 0.211349 0.159495 0.119703 0.089345023 0.066000007 0.047585011 0.032699998 0.02 0.0099999998\",\"1 0.98495197 0.96340603 0.94186503 0.92038703 0.89890802 0.87742901 0.85601801 0.83466089 0.81330389 0.79194689 0.77063751 0.7493782 0.72116601 0.68589991 0.65063488 0.61581838 0.58104151 0.54630423 0.49459019 0.44374019 0.39289111 0.34338111 0.29440311 0.2467411 0.20035011 0.1562241 0.1136021 0.063720062 0.028010041 0.0069600251 8.1754132e-09 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\",\"surface pressure\",\"hPa\",\"1200\",\"0\",\"-1e+30\",\"time longitude latitude\",\"terrain height\",\"m\",\"10000\",\"-1000\",\"-9999\",\"time longitude latitude\",\"tropopause pressure\",\"hPa\",\"1200\",\"0\",\"-1e+30\",\"nitrogen dioxide vertical column determined from fitted slant column and total AMF calculated from surface to top of atmosphere\",\"time longitude latitude\",\"nitrogen dioxide vertical column\",\"time longitude latitude\",\"nitrogen dioxide vertical column uncertainty\",\"molecules/cm^2\",\"-1e+30\",\"molecules/cm^2\",\"-1e+30\",\"gregorian\",\"DIMENSION_SCALE\",\"2024-09-01T16:37:56Z\",\"1409243894.7743\",\"2024-09-01T15:38:15Z\",\"1409240313.15257\",\"scan start time\",\"time\",\"1980-01-06T00:00:00Z\",\"\",\"time\",\"seconds since 1980-01-06T00:00:00Z\",\"2\",\"TEMPO Level 3 nitrogen dioxide product\",\"3\",\"sum of Level 2 pixel overlap areas\",\"time longitude latitude\",\"sum of area weights\",\"km^2\",\"9.96921e+36\",\"1\",\"version\"]],\"container\":\"<table class=\\\"display\\\">\\n <thead>\\n <tr>\\n <th> <\\/th>\\n <th>Name<\\/th>\\n <th>Value<\\/th>\\n <\\/tr>\\n <\\/thead>\\n<\\/table>\",\"options\":{\"columnDefs\":[{\"orderable\":false,\"targets\":0},{\"name\":\" \",\"targets\":0},{\"name\":\"Name\",\"targets\":1},{\"name\":\"Value\",\"targets\":2}],\"order\":[],\"autoWidth\":false,\"orderClasses\":false}},\"evals\":[],\"jsHooks\":[]}</script>\n```\n\n:::\n\n```{.r .cell-code}\nterra_meta_sds <- terra::describe(paste0(\"/vsicurl/\", nc_file), sds = TRUE)\n\nDT::datatable(terra_meta_sds, caption = \"Subdataset-level metadata\")\n```\n\n::: {.cell-output-display}\n\n```{=html}\n<div class=\"datatables html-widget html-fill-item\" id=\"htmlwidget-dd68640b90741409b6c1\" style=\"width:100%;height:auto;\"></div>\n<script type=\"application/json\" data-for=\"htmlwidget-dd68640b90741409b6c1\">{\"x\":{\"filter\":\"none\",\"vertical\":false,\"caption\":\"<caption>Subdataset-level metadata<\\/caption>\",\"data\":[[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\",\"12\",\"13\",\"14\",\"15\",\"16\",\"17\",\"18\",\"19\",\"20\",\"21\",\"22\",\"23\",\"24\",\"25\",\"26\",\"27\",\"28\",\"29\",\"30\",\"31\",\"32\",\"33\",\"34\",\"35\"],[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35],[\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://geolocation/relative_azimuth_angle\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://geolocation/solar_zenith_angle\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://geolocation/viewing_zenith_angle\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://product/main_data_quality_flag\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://product/vertical_column_stratosphere\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://product/vertical_column_troposphere\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://product/vertical_column_troposphere_uncertainty\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://qa_statistics/max_vertical_column_stratosphere_sample\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://qa_statistics/max_vertical_column_total_sample\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://qa_statistics/max_vertical_column_troposphere_sample\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://qa_statistics/max_vertical_column_troposphere_uncertainty_sample\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://qa_statistics/min_vertical_column_stratosphere_sample\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://qa_statistics/min_vertical_column_total_sample\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://qa_statistics/min_vertical_column_troposphere_sample\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://qa_statistics/min_vertical_column_troposphere_uncertainty_sample\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://qa_statistics/num_vertical_column_stratosphere_samples\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://qa_statistics/num_vertical_column_total_samples\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://qa_statistics/num_vertical_column_troposphere_samples\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://qa_statistics/num_vertical_column_troposphere_uncertainty_samples\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://support_data/albedo\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://support_data/amf_cloud_fraction\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://support_data/amf_cloud_pressure\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://support_data/amf_stratosphere\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://support_data/amf_total\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://support_data/amf_troposphere\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://support_data/eff_cloud_fraction\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://support_data/fitted_slant_column\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://support_data/fitted_slant_column_uncertainty\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://support_data/snow_ice_fraction\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://support_data/surface_pressure\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://support_data/terrain_height\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://support_data/tropopause_pressure\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://support_data/vertical_column_total\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://support_data/vertical_column_total_uncertainty\",\"HDF5:\\\"/vsicurl/https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/TEMPO/TEMPO_NO2_L3_V03/2024.09.01/TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc\\\"://weight\"],[\"//geolocation/relative_azimuth_angle\",\"//geolocation/solar_zenith_angle\",\"//geolocation/viewing_zenith_angle\",\"//product/main_data_quality_flag\",\"//product/vertical_column_stratosphere\",\"//product/vertical_column_troposphere\",\"//product/vertical_column_troposphere_uncertainty\",\"//qa_statistics/max_vertical_column_stratosphere_sample\",\"//qa_statistics/max_vertical_column_total_sample\",\"//qa_statistics/max_vertical_column_troposphere_sample\",\"//qa_statistics/max_vertical_column_troposphere_uncertainty_sample\",\"//qa_statistics/min_vertical_column_stratosphere_sample\",\"//qa_statistics/min_vertical_column_total_sample\",\"//qa_statistics/min_vertical_column_troposphere_sample\",\"//qa_statistics/min_vertical_column_troposphere_uncertainty_sample\",\"//qa_statistics/num_vertical_column_stratosphere_samples\",\"//qa_statistics/num_vertical_column_total_samples\",\"//qa_statistics/num_vertical_column_troposphere_samples\",\"//qa_statistics/num_vertical_column_troposphere_uncertainty_samples\",\"//support_data/albedo\",\"//support_data/amf_cloud_fraction\",\"//support_data/amf_cloud_pressure\",\"//support_data/amf_stratosphere\",\"//support_data/amf_total\",\"//support_data/amf_troposphere\",\"//support_data/eff_cloud_fraction\",\"//support_data/fitted_slant_column\",\"//support_data/fitted_slant_column_uncertainty\",\"//support_data/snow_ice_fraction\",\"//support_data/surface_pressure\",\"//support_data/terrain_height\",\"//support_data/tropopause_pressure\",\"//support_data/vertical_column_total\",\"//support_data/vertical_column_total_uncertainty\",\"//weight\"],[\"[1x2950x7750] //geolocation/relative_azimuth_angle (32-bit floating-point)\",\"[1x2950x7750] //geolocation/solar_zenith_angle (32-bit floating-point)\",\"[1x2950x7750] //geolocation/viewing_zenith_angle (32-bit floating-point)\",\"[1x2950x7750] //product/main_data_quality_flag (16-bit integer)\",\"[1x2950x7750] //product/vertical_column_stratosphere (64-bit floating-point)\",\"[1x2950x7750] //product/vertical_column_troposphere (64-bit floating-point)\",\"[1x2950x7750] //product/vertical_column_troposphere_uncertainty (64-bit floating-point)\",\"[1x2950x7750] //qa_statistics/max_vertical_column_stratosphere_sample (64-bit floating-point)\",\"[1x2950x7750] //qa_statistics/max_vertical_column_total_sample (64-bit floating-point)\",\"[1x2950x7750] //qa_statistics/max_vertical_column_troposphere_sample (64-bit floating-point)\",\"[1x2950x7750] //qa_statistics/max_vertical_column_troposphere_uncertainty_sample (64-bit floating-point)\",\"[1x2950x7750] //qa_statistics/min_vertical_column_stratosphere_sample (64-bit floating-point)\",\"[1x2950x7750] //qa_statistics/min_vertical_column_total_sample (64-bit floating-point)\",\"[1x2950x7750] //qa_statistics/min_vertical_column_troposphere_sample (64-bit floating-point)\",\"[1x2950x7750] //qa_statistics/min_vertical_column_troposphere_uncertainty_sample (64-bit floating-point)\",\"[1x2950x7750] //qa_statistics/num_vertical_column_stratosphere_samples (32-bit integer)\",\"[1x2950x7750] //qa_statistics/num_vertical_column_total_samples (32-bit integer)\",\"[1x2950x7750] //qa_statistics/num_vertical_column_troposphere_samples (32-bit integer)\",\"[1x2950x7750] //qa_statistics/num_vertical_column_troposphere_uncertainty_samples (32-bit integer)\",\"[1x2950x7750] //support_data/albedo (32-bit floating-point)\",\"[1x2950x7750] //support_data/amf_cloud_fraction (32-bit floating-point)\",\"[1x2950x7750] //support_data/amf_cloud_pressure (32-bit floating-point)\",\"[1x2950x7750] //support_data/amf_stratosphere (32-bit floating-point)\",\"[1x2950x7750] //support_data/amf_total (32-bit floating-point)\",\"[1x2950x7750] //support_data/amf_troposphere (32-bit floating-point)\",\"[1x2950x7750] //support_data/eff_cloud_fraction (32-bit floating-point)\",\"[1x2950x7750] //support_data/fitted_slant_column (64-bit floating-point)\",\"[1x2950x7750] //support_data/fitted_slant_column_uncertainty (64-bit floating-point)\",\"[1x2950x7750] //support_data/snow_ice_fraction (32-bit floating-point)\",\"[1x2950x7750] //support_data/surface_pressure (32-bit floating-point)\",\"[1x2950x7750] //support_data/terrain_height (16-bit integer)\",\"[1x2950x7750] //support_data/tropopause_pressure (32-bit floating-point)\",\"[1x2950x7750] //support_data/vertical_column_total (64-bit floating-point)\",\"[1x2950x7750] //support_data/vertical_column_total_uncertainty (64-bit floating-point)\",\"[2950x7750] //weight (32-bit floating-point)\"],[2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950,2950],[7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750,7750],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]],\"container\":\"<table class=\\\"display\\\">\\n <thead>\\n <tr>\\n <th> <\\/th>\\n <th>id<\\/th>\\n <th>name<\\/th>\\n <th>var<\\/th>\\n <th>desc<\\/th>\\n <th>nrow<\\/th>\\n <th>ncol<\\/th>\\n <th>nlyr<\\/th>\\n <\\/tr>\\n <\\/thead>\\n<\\/table>\",\"options\":{\"columnDefs\":[{\"className\":\"dt-right\",\"targets\":[1,5,6,7]},{\"orderable\":false,\"targets\":0},{\"name\":\" \",\"targets\":0},{\"name\":\"id\",\"targets\":1},{\"name\":\"name\",\"targets\":2},{\"name\":\"var\",\"targets\":3},{\"name\":\"desc\",\"targets\":4},{\"name\":\"nrow\",\"targets\":5},{\"name\":\"ncol\",\"targets\":6},{\"name\":\"nlyr\",\"targets\":7}],\"order\":[],\"autoWidth\":false,\"orderClasses\":false}},\"evals\":[],\"jsHooks\":[]}</script>\n```\n\n:::\n:::\n\n\nWe will read in the variables we are interested in: stratospheric and tropospheric NO2 vertical column densities, and quality flag.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nno2_trop <- terra::rast(\n nc_file,\n subds = \"//product/vertical_column_troposphere\",\n vsi = TRUE,\n md = TRUE\n)\n\nno2_strat <- terra::rast(\n nc_file,\n subds = \"//product/vertical_column_stratosphere\",\n vsi = TRUE,\n md = TRUE\n)\n\nno2_trop\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\nclass : SpatRaster \nsize : 2950, 7750, 1 (nrow, ncol, nlyr)\ndimensions : longitude, latitude, time (7750, 2950, 1}\nresolution : 0.02, 0.02 (x, y)\nextent : -168, -13, 14, 73 (xmin, xmax, ymin, ymax)\ncoord. ref. : lon/lat WGS 84 (CRS84) (OGC:CRS84) \nsource : TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc \nvarname : /product/vertical_column_troposphere (troposphere nitrogen dioxide vertical column) \nname : vertical_column_troposphere-1 \nunit : molecules/cm^2 \ntime : 2024-09-01 15:38:33 UTC \n```\n\n\n:::\n\n```{.r .cell-code}\nno2_strat\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\nclass : SpatRaster \nsize : 2950, 7750, 1 (nrow, ncol, nlyr)\ndimensions : longitude, latitude, time (7750, 2950, 1}\nresolution : 0.02, 0.02 (x, y)\nextent : -168, -13, 14, 73 (xmin, xmax, ymin, ymax)\ncoord. ref. : lon/lat WGS 84 (CRS84) (OGC:CRS84) \nsource : TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc \nvarname : /product/vertical_column_stratosphere (stratosphere nitrogen dioxide vertical column) \nname : vertical_column_stratosphere-1 \nunit : molecules/cm^2 \ntime : 2024-09-01 15:38:33 UTC \n```\n\n\n:::\n\n```{.r .cell-code}\nquality_flag <- terra::rast(\n nc_file,\n subds = \"//product/main_data_quality_flag\",\n vsi = TRUE,\n md = TRUE\n)\n\nquality_flag\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\nclass : SpatRaster \nsize : 2950, 7750, 1 (nrow, ncol, nlyr)\ndimensions : longitude, latitude, time (7750, 2950, 1}\nresolution : 0.02, 0.02 (x, y)\nextent : -168, -13, 14, 73 (xmin, xmax, ymin, ymax)\ncoord. ref. : lon/lat WGS 84 (CRS84) (OGC:CRS84) \nsource : TEMPO_NO2_L3_V03_20240901T153815Z_S007.nc \nvarname : /product/main_data_quality_flag (main data quality flag) \nname : main_data_quality_flag-1 \ntime : 2024-09-01 15:38:33 UTC \n```\n\n\n:::\n:::\n\n\n### Let's now examine the data in a granulue\n\n\n::: {.cell}\n\n```{.r .cell-code}\nhist(values(no2_trop))\n```\n\n::: {.cell-output-display}\n{width=672}\n:::\n\n```{.r .cell-code}\nhist(values(no2_strat))\n```\n\n::: {.cell-output-display}\n{width=672}\n:::\n:::\n\n\n### Finding 'good' pixels\n\nHow many valid values are there?\n\nNetCDF files have metadata that specify fill values for missing data. `terra` automatically converts these fill values to `NA` when reading the data. We can count the number of non-`NA` values to find how many valid pixels there are.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nsum(!is.na(values(no2_trop)))\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n[1] 8077832\n```\n\n\n:::\n\n```{.r .cell-code}\nsum(!is.na(values(no2_strat)))\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n[1] 8078862\n```\n\n\n:::\n:::\n\n\nHow many pixels with high quality flag, 0, are there?\n\n\n::: {.cell}\n\n```{.r .cell-code}\ntable(values(quality_flag), useNA = \"ifany\")\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n\n 0 1 2 NaN \n 7363629 935837 172356 14390678 \n```\n\n\n:::\n:::\n\n\nNotice that the number of non-fill values and high-quality values are different.\n\n**So, we need to make a mask to remove pixels that are not high quality (`quality_flag == 0`).**\n\n\n::: {.cell}\n\n```{.r .cell-code}\ngood_data_mask <- quality_flag == 0\ngood_data_mask\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\nclass : SpatRaster \nsize : 2950, 7750, 1 (nrow, ncol, nlyr)\nresolution : 0.02, 0.02 (x, y)\nextent : -168, -13, 14, 73 (xmin, xmax, ymin, ymax)\ncoord. ref. : lon/lat WGS 84 (CRS84) (OGC:CRS84) \nsource(s) : memory\nvarname : /product/main_data_quality_flag (main data quality flag) \nname : main_data_quality_flag-1 \nmin value : FALSE \nmax value : TRUE \ntime : 2024-09-01 15:38:33 UTC \n```\n\n\n:::\n:::\n\n\nHow many good pixels are there?\n\n\n::: {.cell}\n\n```{.r .cell-code}\nsum(values(good_data_mask), na.rm = TRUE)\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n[1] 7363629\n```\n\n\n:::\n:::\n\n\nUnfortunate reality - \"good\" pixels may contain negative column.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nmin(no2_trop[good_data_mask], na.rm = TRUE)\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n[1] -5.429767e+16\n```\n\n\n:::\n\n```{.r .cell-code}\nmin(no2_strat[good_data_mask], na.rm = TRUE)\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n[1] 1.525629e+15\n```\n\n\n:::\n:::\n\n\n**Getting physically meaningful pixels**\n\nWe can \"clamp\" the negative values in `no2_trop` to zero.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nno2_trop_clamped <- clamp(no2_trop, lower = 0)\n```\n:::\n\n\nMask the pixels (make them `NA`) where `good_data_mask` is `FALSE`.\n\n\n::: {.cell}\n\n```{.r .cell-code}\ngood_trop_no2 <-\n no2_trop_clamped |>\n terra::mask(good_data_mask, maskvalues = FALSE)\ngood_strat_no2 <-\n no2_strat |>\n terra::mask(good_data_mask, maskvalues = FALSE)\n```\n:::\n\n\n# 6. Working with the data to subset and plot\n\n### Spatial subsetting\n\n\n::: {.cell}\n\n```{.r .cell-code}\nPOI_lat <- 38.0\nPOI_lon <- -96.0\n\ndlat <- 5\ndlon <- 6\n\nextent <- terra::ext(\n POI_lon - dlon,\n POI_lon + dlon,\n POI_lat - dlat,\n POI_lat + dlat\n)\n\nno2_trop_cropped <- terra::crop(good_trop_no2, extent)\nno2_strat_cropped <- terra::crop(good_strat_no2, extent)\n```\n:::\n\n\n### Plotting spatial distribution\n\nWe can use basic plotting functionality from `terra` to visualize the data. Let's first plot tropospheric and stratospheric NO2 columns separately, then plot the total column (sum of the two).\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# Get US state boundaries and convert to terra format\nstates <- states(cb = TRUE, progress_bar = FALSE) |>\n vect()\n\nplot(\n no2_trop_cropped,\n main = \"TEMPO Tropospheric NO2 col (molecules/cm²)\",\n range = c(0, 5e16),\n plg = list(\n x = \"bottom\",\n labels = format(seq(0, 5e16, by = 1e16), scientific = TRUE)\n )\n)\nlines(states, col = \"lightgrey\", lwd = 1)\n```\n\n::: {.cell-output-display}\n{width=672}\n:::\n\n```{.r .cell-code}\nplot(\n no2_strat_cropped,\n main = \"TEMPO Stratospheric NO2 col (molecules/cm²)\",\n plg = list(\n x = \"bottom\",\n labels = format(seq(0, 5e16, by = 1e16), scientific = TRUE)\n )\n)\nlines(states, col = \"lightgrey\", lwd = 1)\n```\n\n::: {.cell-output-display}\n{width=672}\n:::\n\n```{.r .cell-code}\n# Plot with state boundaries\nplot(\n (no2_trop_cropped + no2_strat_cropped),\n range = c(0, 5e16),\n main = \"TEMPO Total NO2 col (molecules/cm²)\",\n plg = list(\n x = \"bottom\",\n labels = format(seq(0, 5e16, by = 1e16), scientific = TRUE)\n )\n)\nlines(states, col = \"lightgrey\", lwd = 1)\n```\n\n::: {.cell-output-display}\n{width=672}\n:::\n:::\n\n",
"supporting": [
"examine-TEMPO-data-R_files"
],
"filters": [
"rmarkdown/pagebreak.lua"
],
"includes": {
"include-in-header": [
"<link href=\"../site_libs/htmltools-fill-0.5.8.1/fill.css\" rel=\"stylesheet\" />\n<script src=\"../site_libs/htmlwidgets-1.6.4/htmlwidgets.js\"></script>\n<link href=\"../site_libs/datatables-css-0.0.0/datatables-crosstalk.css\" rel=\"stylesheet\" />\n<script src=\"../site_libs/datatables-binding-0.34.0/datatables.js\"></script>\n<script src=\"../site_libs/jquery-3.6.0/jquery-3.6.0.min.js\"></script>\n<link href=\"../site_libs/dt-core-1.13.6/css/jquery.dataTables.min.css\" rel=\"stylesheet\" />\n<link href=\"../site_libs/dt-core-1.13.6/css/jquery.dataTables.extra.css\" rel=\"stylesheet\" />\n<script src=\"../site_libs/dt-core-1.13.6/js/jquery.dataTables.min.js\"></script>\n<link href=\"../site_libs/crosstalk-1.2.2/css/crosstalk.min.css\" rel=\"stylesheet\" />\n<script src=\"../site_libs/crosstalk-1.2.2/js/crosstalk.min.js\"></script>\n"
]
},
"engineDependencies": {},
"preserve": {},
"postProcess": true
}
}