Regrid OMI L3 product

Hi Sander,

I’m trying to divide an OMI L3 HCHO by OMI HCHO L3 NO2 averaged over a certain period of time. Given that I’ve now managed to average NO2, and I already could average HCHO, the only remaining issue is that the HCHO product is the only OMI L3 to come with a resolution of 0.1 by 0.1. Since the OMI NO2 L3 product has a resolution of 0.25 by 0.25 don’t I need to regrid the HCHO to a 0.25 by 0.25 grid to do an accurate division?

If so how would I go about doing this?

Here’s my code for merging HCHO L3 products. I tried to regrid in the operations stage but it didn’t work as lat and long are already set at 0.1 by 0.1. Perhaps if I define lat and long myself as you showed me how to do for NO2 this would work?

import coda
import harp
import numpy
from os import listdir

#Local variables 

productlist = []
Folder = r'/Users/varsha.rao/Downloads/OMI_HCHO/'
OutFolder = r'/Users/varsha.rao/Downloads/'
 
#Function for listing files
def list_files1(directory, extension):
    return (f for f in listdir(directory) if f.endswith('.' + extension))

#Adding files to a list
FileList = list_files1(Folder, "nc")
for File in FileList: 
    InFile = Folder + File
    pf = coda.open(InFile)
    try:
        latitude = coda.fetch(pf, '/Latitude')
        longitude = coda.fetch(pf, '/Longitude')
        hcho = coda.fetch(pf, '/key_science_data/column_amount')
    finally:
        coda.close(pf)
    product = harp.Product()
    product.latitude = harp.Variable(latitude, ["latitude"])
    product.latitude.unit = "degree_north"
    product.longitude = harp.Variable(longitude, ["longitude"])
    product.longitude.unit = "degree_east"
    product.hcho_column_number_density = harp.Variable(hcho, ["latitude", "longitude"])
    product.hcho_column_number_density.unit = "molec/cm2"
   
    productlist.append(product)
average = harp.execute_operations(productlist, post_operations="bin();squash(time, (latitude,longitude))")
OutFile =  OutFolder + File[19:23] + File [24:26] + ".nc"

harp.export_product(average, OutFile)

You would indeed have to change the resolution of the HCHO to that of NO2.

This is currently not possible with HARP.
It would require a rebin() operation. It is something that we are thinking of implementing in the future, but we don’t have a schedule for this.

But since the data is raster data (just a 2D array), you might be able to use existing python libraries or GDAL to do this regridding for you.