nleethochawalit / GLACiAR2-master

Creative Commons Attribution Share Alike 4.0 International
6 stars 0 forks source link

Cannot run the code #3

Open Firestar-Reimu opened 1 month ago

Firestar-Reimu commented 1 month ago

I want to run this project

I run python completeness.py -s sex parameters.yaml

and I find that:

Traceback (most recent call last):
  File "/home/firestar/Documents/GLACiAR2-master-master/completeness.py", line 939, in <module>
    main(minimal_file=minimal_file,SExtractor_command=SExtractor_command)
  File "/home/firestar/Documents/GLACiAR2-master-master/completeness.py", line 533, in main
    f_old_hdu = fits.open('%sSciImages/sources_%s_%s_cat.fits'%
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/firestar/.miniconda/lib/python3.12/site-packages/astropy/io/fits/hdu/hdulist.py", line 222, in fitsopen
    return HDUList.fromfile(
           ^^^^^^^^^^^^^^^^^
  File "/home/firestar/.miniconda/lib/python3.12/site-packages/astropy/io/fits/hdu/hdulist.py", line 486, in fromfile
    return cls._readfrom(
           ^^^^^^^^^^^^^^
  File "/home/firestar/.miniconda/lib/python3.12/site-packages/astropy/io/fits/hdu/hdulist.py", line 1221, in _readfrom
    raise OSError(
OSError: No SIMPLE card found, this file does not appear to be a valid FITS file. If this is really a FITS file, try with ignore_missing_simple=True

so I added ignore_missing_simple=True after line 536

And I run again, it says:

WARNING: AstropyDeprecationWarning: The indent function is deprecated and may be removed in a future version.
        Use textwrap.indent() instead. [astropy.io.fits.hdu.hdulist]
WARNING: VerifyWarning: Error validating header for HDU #0 (note: Astropy uses zero-based indexing).
    Header size is not multiple of 2880: 219749
There may be extra bytes after the last HDU or the file is corrupted. [astropy.io.fits.hdu.hdulist]
Traceback (most recent call last):
  File "/home/firestar/Documents/GLACiAR2-master-master/completeness.py", line 940, in <module>
    main(minimal_file=minimal_file,SExtractor_command=SExtractor_command)
  File "/home/firestar/Documents/GLACiAR2-master-master/completeness.py", line 533, in main
    f_old_hdu = fits.open('%sSciImages/sources_%s_%s_cat.fits'%
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/firestar/.miniconda/lib/python3.12/site-packages/astropy/io/fits/hdu/hdulist.py", line 222, in fitsopen
    return HDUList.fromfile(
           ^^^^^^^^^^^^^^^^^
  File "/home/firestar/.miniconda/lib/python3.12/site-packages/astropy/io/fits/hdu/hdulist.py", line 486, in fromfile
    return cls._readfrom(
           ^^^^^^^^^^^^^^
  File "/home/firestar/.miniconda/lib/python3.12/site-packages/astropy/io/fits/hdu/hdulist.py", line 1247, in _readfrom
    raise OSError("Empty or corrupt FITS file")
OSError: Empty or corrupt FITS file
[ble: exit 1][ble: elapsed 10.241s (CPU 104.9%)] python completeness.py -s sex parameters.yaml
Firestar-Reimu commented 1 month ago

Full output:

SciImages.tar.gz

$ python completeness.py -s sex parameters.yaml
2024-07-12 09:32:55.923025
parameter file: parameters.yaml
SExtractor command: sex
Minimal File: True
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LF: ['flat']
redshift: [7.5 8.5]
m_out: [24.  24.5 25.  25.5 26.  26.5 27. ]
M_input: [-23.5 -23.  -22.5 -22.  -21.5 -21.  -20.5 -20. ]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Results will be in test/outdir/
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
running field 0019+4360 

----- SExtractor 2.28.0 started on 2024-07-12 at 09:32:55 with 1 thread

> Setting catalog parameters
> WARNING: Not enough apertures provided in config.:
         some APER photometric values will remain blank 

> Reading Neural Network Weights
> WARNING: Not enough apertures provided in config.:
         some APER photometric values will remain blank 

----- Detecting from: borg_0019+4360_f125w_drz_sci.fits
      "Unnamed" / no ext. header / 2036x2157 / 64 bits (floats)
----- Measuring from: borg_0019+4360_f125w_drz_sci.fits
      "Unnamed" / no ext. header / 2036x2157 / 64 bits (floats)
----- Weighting from: borg_0019+4360_f125w_drz_rms_sclv2.fits
      "Unnamed" / no ext. header / 2036x2157 / 32 bits (floats)
----- Weighting from: borg_0019+4360_f125w_drz_rms_sclv2.fits
      "Unnamed" / no ext. header / 2036x2157 / 32 bits (floats)
(M)   Background: -7.36629e-17 RMS: 0.00800723 / Threshold: 0.0400361  
(D)   Background: -0.000344503 RMS: 0.00855743 / Threshold: 0.00855743 
      Objects: detected 662      / sextracted 512             

> All done (in 1.6 s: 1384.2 lines/s , 328.6 detections/s)

> WARNING: Not enough apertures provided in config.:
         some APER photometric values will remain blank 

> WARNING: Not enough apertures provided in config.:
         some APER photometric values will remain blank 

> WARNING: Not enough apertures provided in config.:
         some APER photometric values will remain blank 

> WARNING: Not enough apertures provided in config.:
         some APER photometric values will remain blank 

> WARNING: Not enough apertures provided in config.:
         some APER photometric values will remain blank 

> WARNING: Not enough apertures provided in config.:
         some APER photometric values will remain blank 

> WARNING: Not enough apertures provided in config.:
         some APER photometric values will remain blank 

> WARNING: Not enough apertures provided in config.:
         some APER photometric values will remain blank 

.....
WARNING: AstropyDeprecationWarning: The indent function is deprecated and may be removed in a future version.
        Use textwrap.indent() instead. [astropy.io.fits.hdu.hdulist]
WARNING: VerifyWarning: Error validating header for HDU #0 (note: Astropy uses zero-based indexing).
    Header size is not multiple of 2880: 219749
There may be extra bytes after the last HDU or the file is corrupted. [astropy.io.fits.hdu.hdulist]
Traceback (most recent call last):
  File "/home/firestar/Documents/GLACiAR2-master-master/completeness.py", line 941, in <module>
    main(minimal_file=minimal_file,SExtractor_command=SExtractor_command)
  File "/home/firestar/Documents/GLACiAR2-master-master/completeness.py", line 534, in main
    f_old_hdu = fits.open('%sSciImages/sources_%s_%s_cat.fits'%
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/firestar/.miniconda/lib/python3.12/site-packages/astropy/io/fits/hdu/hdulist.py", line 222, in fitsopen
    return HDUList.fromfile(
           ^^^^^^^^^^^^^^^^^
  File "/home/firestar/.miniconda/lib/python3.12/site-packages/astropy/io/fits/hdu/hdulist.py", line 486, in fromfile
    return cls._readfrom(
           ^^^^^^^^^^^^^^
  File "/home/firestar/.miniconda/lib/python3.12/site-packages/astropy/io/fits/hdu/hdulist.py", line 1247, in _readfrom
    raise OSError("Empty or corrupt FITS file")
OSError: Empty or corrupt FITS file
Firestar-Reimu commented 1 month ago

After:

  1. set CATALOG TYPE = FITS 1.0
  2. set Jaguar_spec: false

I found:

redshift 1/2, LF 1/1, M_input 1/8
   Input Magnitude bin M = -23.5 mag:
       simulate galaxies with M = [-23.48120893 -23.54666019 -23.58730502 -23.25083249 -23.62830815
 -23.67559068 -23.68387039 -23.41194661 -23.46812404 -23.46387058]
   iteration 1/10:
       theoretical m = [23.61615116 30.96032722 24.15557927 23.78035095 23.69918497]Traceback (most recent call last):
  File "/home/firestar/Documents/GLACiAR2-master-master/completeness.py", line 941, in <module>
    main(minimal_file=minimal_file,SExtractor_command=SExtractor_command)
  File "/home/firestar/Documents/GLACiAR2-master-master/completeness.py", line 732, in main
    xpos, ypos = creation_of_galaxy.galaxies_positions(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/firestar/Documents/GLACiAR2-master-master/creation_of_galaxy.py", line 166, in galaxies_positions
    xr = random.randrange(s2 + 1, image_data.shape[0] - s2 - 1, 1)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/firestar/.miniconda/lib/python3.12/random.py", line 301, in randrange
    istart = _index(start)
             ^^^^^^^^^^^^^
TypeError: 'float' object cannot be interpreted as an integer

So I think, maybe s2 = size // 2 not size / 2, so that size // 2 is always an integer

image

Firestar-Reimu commented 1 month ago

even_number / 2 always return a float in python now:

In [1]: a = 4

In [2]: b = [i for i in range(a/2)]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[2], line 1
----> 1 b = [i for i in range(a/2)]

TypeError: 'float' object cannot be interpreted as an integer

In [3]: b = [i for i in range(a//2)]

In [4]: b
Out[4]: [0, 1]