HYPERNETS / hypernets_processor

Processor for Hypernets field data to generate the user products
9 stars 3 forks source link

Failed: UnboundLocalError #140

Closed saberioon closed 2 years ago

saberioon commented 3 years ago

When I am trying to process some sequences, I am getting this error:

No SN for hypstar instrument!                                                           
Processing Anomalies: ['x']                                                              
Failed: UnboundLocalError("local variable 'instrument_id' referenced before assignment")

I am attaching one of the sequence here : SEQ20210626T100046.zip

Any suggestion to fix it?

javierconcha commented 3 years ago

Do you have the "sn_hypstar" parameter in your config file?

saberioon commented 3 years ago

No , I don't and I never thought it should be there

clemgoyens commented 3 years ago

Hi Mehdi, If you want I can provide you a script to add the serial number of your hypstar in the metadata. But indeed, when configuring the instrument you should add the SN of the instrument otherwise the processor is not able the check for the appropriate calibration files.

saberioon commented 3 years ago

Hi Mehdi, If you want I can provide you a script to add the serial number of your hypstar in the metadata. But indeed, when configuring the instrument you should add the SN of the instrument otherwise the processor is not able the check for the appropriate calibration files.

Hi Clemence,

I appreciate it if you send me the script, but I wonder where this code should be added? Why it is not listed in the config file? Does it cross-check it with any database?

clemgoyens commented 3 years ago

Yes indeed, it should be in here: https://github.com/HYPERNETS/hypernets_tools/blob/main/config_hypernets.ini.template But I still can't see it there! @corizzi any idea why?

clemgoyens commented 3 years ago

This should work:

!/bin/bash

for file in $(find BSBE/03/SEQ20210311T08*/metadata.txt); do echo Processing $file if grep -F "[Metadata]" $file then

code if found

  echo Metadata header already found in $file 

else

code if not found

cat example_of_header.txt $file > $file.modified
mv $file.modified $file

fi if grep -F -e 'hypstar_sn' -e 'sn_hypstar' $file then echo SN instrument already in $file else sed -i.bak "/^datetime/a $(grep "hypstar_sn" example_of_header.txt)" $file fi done

#########

And in example header you should have something like this: [Metadata] principal_investigator = RBINS datetime = 20210309T093159 hypstar_sn = 120241 site_id = BSBE latitude = 50.98857 longitude = 2.835213 protocol_file_name = hypernets/resources/sequences_samples/sequence_water_1_STD.csv

corizzi commented 3 years ago

Yes indeed, it should be in here: https://github.com/HYPERNETS/hypernets_tools/blob/main/config_hypernets.ini.template But I still can't see it there! @corizzi any idea why?

Hi @clemgoyens, It still has to be filled by hand in the current version. I added the placeholder in the template as a reminder : https://github.com/HYPERNETS/hypernets_tools/commit/887bdef14c3de095f3823a62ef49320b016ea940

clemgoyens commented 2 years ago

This issue is similar to issue #122. See #122 for further solutions!