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

@sander.niemeijer
Hi :slight_smile:

I have the same issue, but im looking for a way where the loop skips the file ‘with no data’ and moves on to the next file, as i am working with hundreds of files.
Do you have any suggestions?

1 Like

Hey Mariamt,

Can you give us some more information? Did you try the suggestion of @sander.niemeijer, replicated below ? what happens when you do?

Harp v1.12 or later is needed.

try:
product = harp.import_product(infile, operations=’…’)
except harp.NoDataError:
pass

Best wishes,
MariLiza

1 Like

Where you able to find a solution, I’m facing similar issue

Well, I did find the solution! :slight_smile: The original suggested by @sander.niemeijer and which I also suggested to @mariamt above.

Unfortunately, your code may be collapsing for numerous other reasons so, unless you provide with concrete examples of what goes wrong… there is not way to tell!

Good luck,
MariLiza