miguelinux314 / experiment-notebook

enb (experiment notebook) is a python library/framework to design, run and analyze computer-based experiments. Persistence, parallelization and plotting can be automatically handled by enb, to help you develop efficient and reproducible science.
https://miguelinux314.github.io/experiment-notebook/
Other
6 stars 10 forks source link

TypeError: 'NoneType' when using 'ccsds_lcnl.compress' #59

Closed ohadshapira closed 3 months ago

ohadshapira commented 3 months ago

Running the following code on this satellite data (AVIRIS): https://daac.ornl.gov/cgi-bin/dsviewer.pl?ds_id=1988

if __name__ == '__main__':
    ccsds_lcnl=CCSDS_LCNL(bin_dir='./bin',sample_encoding_order=0,large_p = 0,local_sum_type = 0,prediction_mode=0) 

    print(ccsds_lcnl)
ccsds_lcnl.compress(original_path='./files/ang20210401t150456_rfl_v2z1/ang20210401t150456_rfl_v2z1',compressed_path='./files/ang20210401t150456_rfl_v2z1/ang20210401t150456_rfl_v2z1.comp')

Getting an unknown issue about original_file_info["bytes_per_sample"] :

<CCSDS_LCNL('a_vector'=None, 'entropy_coder_type'=1, 'large_p'=0, 'r_vector'=None, 'sample_encoding_order'=0)>

Traceback (most recent call last):
  File "/home/ohad/lcnl/lcnl_codecs.py", line 433, in <module>
    ccsds_lcnl.compress(original_path='./files/ang20210401t150456_rfl_v2z1/ang20210401t150456_rfl_v2z1',compressed_path='./files/ang20210401t150456_rfl_v2z1/ang20210401t150456_rfl_v2z1.comp')
  File "/home/ohad/lcnl/lcnl_codecs.py", line 263, in compress
    image_params = self.get_image_params(original_path=original_path, original_file_info=original_file_info)
  File "/home/ohad/lcnl/lcnl_codecs.py", line 238, in get_image_params
    if original_file_info["bytes_per_sample"] == 1:
TypeError: 'NoneType' object is not subscriptable

Is the _original_fileinfo input is mandatory? Is .hdr file acceptable? what is the expected input for a file?

Do you have an example of use?

Thanks!

miguelinux314 commented 3 months ago

Thanks for your feedback!

Yes, the original_file_info parameter is mandatory if you call the compress method of the lcnl codec. The reason is enb needs information about the image size, sample type, etc.

Typically, enb obtains this information from the file name (see https://miguelinux314.github.io/experiment-notebook/lossless_compression_example.html#data-curation). You can use the enb.isets.file_path_to_geometry_dict method to attempt to get a dictionary that can be passed as the original_file_info parameter.

Note that, if you use the compression experiment classes (https://miguelinux314.github.io/experiment-notebook/lossless_compression_example.html#lossless-compression-experiment), this is done automatically for you.

For an example, I recommend you look into a lossless compression experiment:

enb plugin install lossless-compression ./lc cd lc enb plugin install lcnl plugins/lcnl

Note how the sample image in this project template is called "image_u8be-2x128x128.raw" so that the geometry can be obtained.

ohadshapira commented 3 months ago

Thank you Miguel! I was able to compress using lossless-compression-experiment.py example file and it worked for CCSDS 121.0-b-3. How do I install the plugin/codec for CCSDS 123.0-b-2?

I have downloaded the binaries from CNES but unable to make enb recognize it.

run: enb plugin install lcnl ./plugins/lcnl -v export: all binaries to ./plugins/lcnl/ chmod 777./plugins/lcnl/*

Am I missing something?

Thank you for this amazing repo!

miguelinux314 commented 3 months ago

Hi Ohad,

The process is as you describe it, so I'm not sure what could be failing. Can you provide your exact inputs, the error output (and perhaps the output of 'ls -lR')?

Thanks,

On Tue, 6 Aug 2024, 18:26 Ohad Shapira, @.***> wrote:

Thank you Miguel! I was able to compress using lossless-compression-experiment.py example file and it worked for CCSDS 121.0-b-3. How do I install the plugin/codec for CCSDS 123.0-b-2?

I have downloaded the binaries from CNES but unable to make enb recognize it.

run: enb plugin install lcnl ./plugins/lcnl -v export: all binaries to ./plugins/lcnl/ chmod 777./plugins/lcnl/*

Am I missing something?

Thank you for this amazing repo!

— Reply to this email directly, view it on GitHub https://github.com/miguelinux314/experiment-notebook/issues/59#issuecomment-2271682513, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEBMT4ZDLVQDMO7VRZ7KXDDZQD2LBAVCNFSM6AAAAABL4KWPVCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZRGY4DENJRGM . You are receiving this because you modified the open/close state.Message ID: @.***>