Add additional support for more product files by producing similar product files with already-supported product files

Like the question I asked in github, is there any possibility to generate a fake product file by replacing the original values of the geolocation variable and concerned variable with values from another unsupported product file? This should help support more product files.

You have to be aware that HARP supports two types of products:

Trying to modify a product which is in an external format to allow it to be read by HARP does not make sense. You are then better of creating your own product having HARP conventions directly (i.e. creating your own HARP importer).

Creating a converter is not that difficult if you use the HARP python interface.

A template script for how to do this is the following:

import numpy as np
from datetime import datetime, timedelta

import harp

product = harp.Product()

# replace this section with reading routines to get data from your own product
times = [datetime(2020,1,1) + timedelta(seconds=x) for x in range(100)]
latitude_bounds = np.zeros([100,4])
longitude_bounds = np.zeros([100,4])
co2 = np.zeros([100])


# datetime
time_origin = datetime(2000, 1, 1)
times = np.array([(t - time_origin).total_seconds() / (24 * 60 * 60) for t in times])
product.datetime = harp.Variable(times, ["time"])
product.datetime.unit = "days since 2000-01-01"

# latitude
product.latitude_bounds = harp.Variable(latitude_bounds, ["time", None])
product.latitude_bounds.unit = "degree_north"
# longitude
product.longitude_bounds = harp.Variable(longitude_bounds, ["time", None])
product.longitude_bounds.unit = "degree_east"
# value
product.CO2_column_number_density = harp.Variable(co2, ["time"])
product.CO2_column_number_density.unit = "molec/cm^2"  # replace with actual unit of measurement

# Export as HARP product
harp.export_product(product, "myproduct.nc")

If you want to create a L3 grid from it, you don’t even have to export to a file. You could then directly use the following to get your grid:

gridded_product = harp.execute_operations(product, 'bin_spatial(....)')
1 Like

Thanks for your help. Harp is a powerful tool and can do more than I thought. I obtained the L3 grid data of OCO-2 product.