2. Loading ASCAT Data
To load soil moisture data from a specific grid data point, you can use the read_grid_point function provided by SMADI. This function allows you to extract ASCAT soil moisture time series for a given location.
If you already have the data downloaded in NetCDF format on your local machine, follow these steps to load the data:
Note: It is important to execute the cells sequentially, starting from the top and moving downwards. Certain later examples rely on the results or data generated by preceding cells!
[1]:
import pandas as pd
from smadi.data_reader import read_grid_point
# Set display options
pd.set_option("display.max_columns", 8) # Limit the number of columns displayed
pd.set_option("display.precision", 2) # Set precision to 2 decimal places
# Define the path to the ASCAT data
# Adjust the path based on the notebook's environment
# For local machine:
data_path = "/home/m294/ascat_dataset"
# Define the coordinates of the observation point
# Example: A grid point in Morocco
lon = -7.382
lat = 33.348
# Alternatively, you can define the location using a Fibonaci grid ID
# For more information, see: https://dgg.geo.tuwien.ac.at/
gpid = 3611180
# Define the location of the observation point
loc = (lon, lat) # or loc = gpid
# Extract ASCAT soil moisture time series for the given location
data = read_grid_point(
loc=loc, ascat_sm_path=data_path, read_bulk=False, era5_land_path=None
) # Provide the path to the ERA5-Land data if you want mask snow
# and frozen soil conditions. For more information about
# the dataset see ERA5-Land data documentation and to download
# use the CDS API or https://ecmwf-models.readthedocs.io/en/latest/
# Get the ASCAT soil moisture time series
ascat_ts = data.get("ascat_ts")
# Display the first few rows of the time series data
ascat_ts.head()
Reading ASCAT soil moisture: /home/m294/ascat_dataset
ASCAT GPI: 3611180 - distance: 23.713 m
Warning: ERA5-Land not found: None
Warning: ERA5 Land not found - ASCAT soil moisture not masked!
[1]:
| sm | sm_noise | as_des_pass | ssf | ... | sigma40 | sigma40_noise | num_sigma | sm_valid | |
|---|---|---|---|---|---|---|---|---|---|
| 2007-01-01 21:02:04.161 | 34.86 | 3.24 | 0 | 0 | ... | -12.27 | 0.19 | 3 | True |
| 2007-01-02 11:03:22.807 | 23.16 | 3.27 | 1 | 0 | ... | -13.05 | 0.19 | 3 | True |
| 2007-01-03 10:42:47.739 | 33.05 | 3.23 | 1 | 0 | ... | -12.39 | 0.19 | 3 | True |
| 2007-01-03 22:00:39.007 | 25.60 | 3.24 | 0 | 0 | ... | -12.88 | 0.19 | 3 | True |
| 2007-01-05 10:01:27.519 | 28.73 | 3.24 | 1 | 0 | ... | -12.67 | 0.19 | 3 | True |
5 rows × 16 columns
In the above code:
loc: Specifies the location of the observation point. You can define it either by providing latitude and longitude coordinates or by specifying the grid point ID.ascat_sm_path: Specifies the path to the ASCAT soil moisture data file or directory.read_bulk: Determines whether to load the entire ASCAT dataset into memory (True) or read only the necessary data for the specified location (False), which can be more memory-efficient.
[2]:
# Extract the soil moisture time series from the ASCAT dataset
sm_ts = ascat_ts.get("sm")
sm_ts
[2]:
2007-01-01 21:02:04.161 34.86
2007-01-02 11:03:22.807 23.16
2007-01-03 10:42:47.739 33.05
2007-01-03 22:00:39.007 25.60
2007-01-05 10:01:27.519 28.73
...
2022-12-29 21:57:39.465 50.80
2022-12-31 09:58:27.173 39.88
2022-12-31 10:46:30.147 43.07
2022-12-31 21:16:18.245 45.15
2022-12-31 22:04:22.287 50.78
Name: sm, Length: 12450, dtype: float32