emsellem / pymusepipe

MIT License
9 stars 9 forks source link

Error when saving Pointing table #19

Closed cloud182 closed 1 year ago

cloud182 commented 1 year ago

Hi Eric,

I was trying to save the pointing table, to manually remove some frames that I do not want in the mosaic. The code I used is the following:

alignment_dir = '/data/beegfs/astro-storage/groups/schinnerer/PHANGS/MUSE/live/Data/PHANGS_EXT/NGC0253/Alignment/'
pt = PointingTable(folder=alignment_dir, filtername='WFI_BB')
pt.write(nameout='/data/beegfs/astro-storage/groups/schinnerer/PHANGS/MUSE/Test/Config_test_NGC253/v0/pt_table2.dat', format='ascii.csv')

however I get the following error:

Cell In[4], line 1
----> 1 pt.write(nameout='/data/beegfs/astro-storage/groups/schinnerer/PHANGS/MUSE/Test/Config_test_NGC253/v0/pt_table2.dat', format='ascii.csv')

File ~/miniconda3/envs/py31/lib/python3.10/site-packages/pymusepipe/util_image.py:1254, in PointingTable.write(self, overwrite, **kwargs)
   1252 # Reading the input
   1253 folder = kwargs.pop("folder", self.folderout)
-> 1254 nameout = kwargs.pop("nameout", self.tablename)
   1255 if nameout is None:
   1256     upipe.print_error("No provided output filename")

AttributeError: 'PointingTable' object has no attribute 'tablename'

Cheers, Enrico

emsellem commented 1 year ago

Hi Enrico. Could you confirm pls that this bug is still there? Looking at the code it should not do that (as tablename is allocated during the init).

cloud182 commented 1 year ago

Hi Eric,

I think this error is fixed. However, an unrelated error arose in the new version:

Traceback (most recent call last): File "/data/beegfs/astro-storage/groups/schinnerer/PHANGS/MUSE/Test/Config_test_NGC253/v0/mosaicing.py", line 36, in phangs = set_reduct(['NGC0253']) File "/data/beegfs/astro-storage/groups/schinnerer/PHANGS/MUSE/Test/Config_test_NGC253/v0/mosaicing.py", line 27, in set_reduct phangs = MusePipeSample(thisdic, rc_filename=rcfile, cal_filename=calfile, PHANGS=True, File "/home/congiu/miniconda3/envs/py31/lib/python3.10/site-packages/pymusepipe/target_sample.py", line 231, in init self._init_targets(**kwargs) File "/home/congiu/miniconda3/envs/py31/lib/python3.10/site-packages/pymusepipe/target_sample.py", line 335, in _init_targets init_comb_target = MusePointings(targetname=targetname, File "/home/congiu/miniconda3/envs/py31/lib/python3.10/site-packages/pymusepipe/combine.py", line 239, in init self.goto_origfolder() File "/home/congiu/miniconda3/envs/py31/lib/python3.10/site-packages/pymusepipe/combine.py", line 646, in goto_origfolder self.goto_folder(self.paths.orig, addtolog=addtolog, verbose=False) TypeError: MusePointings.goto_folder() got an unexpected keyword argument 'verbose'

just removing verbose=False in File "/home/congiu/miniconda3/envs/py31/lib/python3.10/site-packages/pymusepipe/combine.py", line 646, seems to do the job.

Cheers, Enrico

cloud182 commented 1 year ago

I also tried to read the table after saving it, and the following error arose:


  File "/data/beegfs/astro-storage/groups/schinnerer/PHANGS/MUSE/Test/Config_test_NGC253/v0/mosaicing.py", line 41, in <module>
    pt = PointingTable(input_table='test_pt.dat')
  File "/home/congiu/miniconda3/envs/py31/lib/python3.10/site-packages/pymusepipe/util_image.py", line 1156, in __init__
    if not os.path.exists(self.fullname):
AttributeError: 'PointingTable' object has no attribute 'fullname'. Did you mean: 'fullnameout'?```
emsellem commented 1 year ago

Regarding the first one: there is no such thing as verbose on that line, so maybe a versioning issue?

For the second one, yes, a typo. Was fulltablename instead of fullname. Should have tested it. Hope there are no more... ;-)

cloud182 commented 1 year ago

Great thanks! I'll try to test it out!

jusneuma commented 1 year ago

Some follow-up errors

These following errors occurred when reading a pointing table in fits file format:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jneumann/pymusepipe/src/pymusepipe/util_image.py", line 1157, in __init__
    self.read()
  File "/home/jneumann/pymusepipe/src/pymusepipe/util_image.py", line 1379, in read
    self.tablename = kwargs.pop("filename", self.filename)
AttributeError: 'PointingTable' object has no attribute 'filename'. Did you mean: 'tablename'?

Just commenting out line 1379 solved the issue . Next error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jneumann/pymusepipe/src/pymusepipe/util_image.py", line 1157, in __init__
    self.read()
  File "/home/jneumann/pymusepipe/src/pymusepipe/util_image.py", line 1383, in read
    if not os.path.exists(self.fullname):
AttributeError: 'PointingTable' object has no attribute 'fullname'. Did you mean: 'fullnameout'?

Changing fullname to fulltablename solved the issue. Next error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jneumann/pymusepipe/src/pymusepipe/util_image.py", line 1157, in __init__
    self.read()
  File "/home/jneumann/pymusepipe/src/pymusepipe/util_image.py", line 1384, in read
    qtable = QTable.read(self.fulltablename, format=self.table_format, guess=self.guess,
  File "/home/jneumann/anaconda3/musedr/lib/python3.10/site-packages/astropy/table/connect.py", line 62, in __call__
    out = self.registry.read(cls, *args, **kwargs)
  File "/home/jneumann/anaconda3/musedr/lib/python3.10/site-packages/astropy/io/registry/core.py", line 212, in read
    data = reader(*args, **kwargs)
TypeError: read_table_fits() got an unexpected keyword argument 'guess'

Reading the fits format doesn't take and doesn't need a format "guess". For now, I just added an if self.table_format=='fits': qtable = QTable.read(self.fulltablename, format=self.table_format,**kwargs) and else: qtable = QTable.read(self.fullname, format=self.table_format, guess=self.guess, **kwargs). This solved the issue for me. I leave it to you to do it nicer. :)

emsellem commented 1 year ago

I made a few modifications. Clearly this was wrong/bugged, with spelling mistakes and problems of changed parameter names. Hope it does it now.