Click here
to download this notebook.
How to merge two NadirData
It is possible to merge two NadirData objects in order to ease the manipulation and comparison of data coming from different sources [doc].
[1]:
import os
from casys import NadirData, CasysPlot, DateHandler, Field, TextParams
NadirData.enable_loginfo()
Correctly set your NadirData and their fields
Create your fields
When working with multiple sources with the intent to merge them, fields must have different names in each NadirData object.
swh_s3pp = Field("SWH_S3PP", source="SWH.ALTI") swh_pdgs = Field("SWH_PDGS", source="SWH.ALTI")Load your data
In order to merge NadirData objects, required raw data have to be added in computed.
As we are working on different “GES_TABLE_DIR” environments a “small trick” is needed.
Set the first environment, create your first NadirData and store it.
Reload your notebook
Set the second environment, create your second NadirData and, optionally, store it.
First data source (Sentinel 3 PDGS): the merged source
# PDGS os.environ["GES_TABLE_DIR"] = "/archive/PMC/peachis3apdgs/data/TABLES/DSC/" start = DateHandler.from_orf("T_HS3A_PDGS_MAR_ORF", 25, 1, pos="first") end = DateHandler.from_orf("T_HS3A_PDGS_MAR_ORF", 25, 10, pos="last") ad_pdgs = NadirData( date_start=start, date_end=end, source="TABLE_T_HS3A_S3PDGS_SARM_MAR_B", orf="T_HS3A_PDGS_MAR_ORF", time="time", longitude="LONGITUDE", latitude="LATITUDE", )Raw data have to be added and computed before the merge operation.
ad_pdgs.add_raw_data("SWH_PDGS", swh_pdgs) ad_pdgs.compute() ad_pdgs.store("ad_pdgs.back", overwrite=True)Second data source (Sentinel 3 S3PP): the main source
# S3PP os.environ["GES_TABLE_DIR"] = "/data/peachis3app_ex/data/TABLES/DSC/"start = DateHandler.from_orf("T_HS3A", 25, 1, pos="first") end = DateHandler.from_orf("T_HS3A", 25, 10, pos="last") ad_s3pp = NadirData( date_start=start, date_end=end, source="TABLE_T_HS3A_S3PP_B", orf="T_HS3A", time="time", longitude="LONGITUDE", latitude="LATITUDE", )ad_s3pp.add_raw_data("SWH_S3PP", swh_s3pp) ad_s3pp.compute() ad_s3pp.store(os.path.join(os.environ["RESOURCES_DIR"], "ad_s3pp.back"), overwrite=True)You will receive these kinds of warnings when loading an NadirData created with an ORF and/or Table you cannot access. It means you will be limited to existing data and won’t be able to read new ones or use anything involving and the ORF.
ad_pdgs = NadirData.load(os.path.join(os.environ["RESOURCES_DIR"], "ad_pdgs.back"))ad_pdgs.dataWe’re able to add a statistic using existing data
ad_pdgs.add_time_stat("SWH Stat", field=swh_pdgs, freq="30min") ad_pdgs.compute()ad_s3pp = NadirData.load(os.path.join(os.environ["RESOURCES_DIR"], "ad_s3pp.back"))ad_s3pp.dataMerge and play with your new NadirData
We’re merging using a simple linear interpolation.
ad_s3pp.merge_data(data=cd_pdgs, interp=True, method="linear")ad_s3pp.dataWe can now use the merged fields as any other:
To compute a statistic
To create new fields usings CLIPs