Atmospheric Toolbox

harp.NoDataError

Greetings Sander,

I apologize for having to ask you, but my python knowledge is limited.

I am guessing from the error I am getting [AttributeError: module ‘harp’ has no attribute ‘NoDataError’] that this is not the way to use the exception:

try:
product = harp.import_product(infile,operations = ‘validity>0.5;point_distance(40.634,25.456,50[km]);
derive(NO2_column_number_density[Pmolec/cm2]);derive(NO2_column_number_density_uncertainty[Pmolec/cm2]);
derive(NO2_slant_column_number_density[Pmolec/cm2]);derive(NO2_slant_column_number_density_uncertainty[Pmolec/cm2]);
derive(tropospheric_NO2_column_number_density[Pmolec/cm2]);derive(tropospheric_NO2_column_number_density_uncertainty[Pmolec/cm2]);
derive(stratospheric_NO2_column_number_density[Pmolec/cm2]); derive(stratospheric_NO2_column_number_density_uncertainty[Pmolec/cm2]);
keep(latitude, longitude, latitude_bounds,longitude_bounds,solar_zenith_angle,sensor_zenith_angle,scan_subindex,NO2_column_number_density,
tropospheric_NO2_column_number_density,stratospheric_NO2_column_number_density,NO2_column_number_density_uncertainty,
tropospheric_NO2_column_number_density_uncertainty,stratospheric_NO2_column_number_density_uncertainty,cloud_fraction,cloud_pressure, orbit_index,NO2_slant_column_number_density,
NO2_slant_column_number_density_uncertainty,datetime_start,datetime_length)’)
except:
harp.NoDataError

Can you enlighten me, please?
Many thanks
MariLiza

You should use:

try:
    product = harp.import_product(infile, operations='....')
except harp.NoDataError:
    # do something...
    # e.g. ignore error by calling 'pass'
    pass

:vulcan_salute:

and thank you!

MariLiza

Further to my previous note, apparently my harp module really doesn’t have the No.Data.Error attribute, see here:

print(dir(harp))
[‘CLibraryError’, ‘Error’, ‘Product’, ‘UnsupportedDimensionError’, ‘UnsupportedTypeError’, ‘Variable’, ‘builtins’, ‘cached’, ‘doc’, ‘file’, ‘loader’, ‘name’, ‘package’, ‘path’, ‘spec’, ‘_harpc’, ‘_harppy’, ‘concatenate’, ‘convert_unit’, ‘execute_operations’, ‘export_product’, ‘get_encoding’, ‘import_product’, ‘set_encoding’, ‘to_dict’, ‘version’]

I am running spyder 5.0.0. with python 3.7.9, on a linux machine.

This seems to work.

except harp.Error:
pass

A bit strange, no?
MariLiza

Then you are probably running a harp version from before 1.12. This error type got added to the global harp namespace in 1.12.

Good morning!
You are right, of course, I was doing conda update but for some reason it does not update my environment to the latest version. I asked our sys admins about it.
Best wishes
MariLiza