Atmospheric Toolbox

HARP - harpmerge - Argument file name

Good morning,
I store the directory path for the input files and output file into a variable.
I would like to use this variable when calling harpmerge (with python). Does someone know how could I refer to the variable when calling harpmerge? (so far I could only type the path directly into the call)
input_files = input_path + “/S5P_OFFL_L2__NO2____*.nc”
output_file = input_path + “/”
!harpmerge -a ‘list of operations’ input_files output_file

harp considers the string “input_files” and “output_file” and not the variable.

I am not sure what you mean when you say “calling harpmerge (with python)”. The code you are showing is not python code. Where exactly are you trying to run that code? Is it a linux shell?

Are you perhaps using ipython? If so, have a look at the documentation

I just checked and I am using python 3.7.10 (python and ipython give me the same version number). Thanks for the documentation link, I will use it.

I started from the RUS training for S5P NO2 analysis using Jupyter Notebook.
The original code is:
!harpmerge -ap ‘bin(); squash(time, (latitude,longitude))’
-a ‘latitude >= 40 [degree_north]; latitude <=60 [degree_north];
longitude>=-22 [degree_east];longitude<=26 [degree_east];
derive(longitude {longitude});derive(latitude {latitude});

I would like to replace the last two lines with the names of my variables: input_files and output_file.

Have you looked at the ipython documentation link that I provided?
It actually shows you how to do this.

I tried prefixing the variable with $ without success.

I am not that familiar with passing arguments to these ipython shell commands, so I can’t help you with that. You should probably ask on an ipython forum.

If you use python, I would rather recommend to use the harp python interface and use harp.import_product and harp.export_product. There are plenty of threads on this forum that shows you how to use these functions.