jacopo-chevallard / BEAGLE-general

Basic information to get started with the galaxy spectral modelling tool Beagle
https://www.iap.fr/beagle/
9 stars 0 forks source link

"SIGSEGV: Segmentation fault - invalid memory reference." when attempting to use the MIRI filters #34

Closed kevinhainline closed 7 years ago

kevinhainline commented 7 years ago

I have two issues. I was trying to add the MIRI filters to the BEAGLE filter list, and first, I found that _addfilters will spit out a segmentation fault if the filterfrm.res file is too long. So I took the NIRCam and MIRI filters and put them into a separate filterfrm.res file, and ran add_filters, which worked this time, creating a FILTERBIN.RES file that I then used to run BEAGLE (I updated the filters file in the parameter file).

Here is what happens:

% docker run --rm -it -v /Users/knh/Desktop/NIRCam/BEAGLE/BEAGLE-general-master:/BEAGLE_virtual_workdir --env-file env.list beagletool/beagle:0.8.2 --parameter-file /BEAGLE_virtual_workdir/params/BEAGLE_mock_Stacey.param --mock

 Reading Filter File: /BEAGLE_virtual_workdir/filters/FILTERBIN.RES
  30 filters defined, out of 500                                maximum     ...done
 ---> fixed                         sfh_type                                   0
 ---> gridded                       metallicity                                0
 ---> gridded                       mass                                       0
 ---> dependent                     sfr                                        0
 ---> gridded                       redshift                                   0
 ---> fixed                         formation_redshift                         0
 ---> dependent                     nebular_logU                               0
 ---> fixed                         nebular_xi                                 0
 ---> dependent                     nebular_Z                                  0
 ---> fixed                         attenuation_type                           0
 ---> fixed                         tauV_eff                                   0
 ---> fixed                         mu                                         0
 n_fitted:            0
 --- LINEAR:  X0 =  6.011E+04 is outside X range --- 9.000E+02 6.010E+04      2362
 ---   Error reported only once. It may occur more than once. ---

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7F62FDDFEE08
#1  0x7F62FDDFDF90
#2  0x7F62FD53049F
#3  0x4B6091 in sort2_ at sort2.f:13
#4  0x4B4E5B in build_filter_array_ at filter_n.f:189
#5  0x4B520F in filtr_master_ at filter_n.f:61
#6  0x4B566E in filtr_master_ at filter_n.f:17
#7  0x42F97C in __galaxy_sed_MOD_compute_sed at galaxy_SED.f90:486 (discriminator 14)
#8  0x406DC8 in MAIN__ at BEAGLE.f90:462

Any idea what's going on?

jacopo-chevallard commented 7 years ago

Hi Kevin, that's interesting, we had exactly the same issue yesterday with @camipacifici and couldn't understand the origin of the problem... As you noticed, everything seems working fine when using the original filterfrm.res to create the binary FILTERBIN.RES, while using a different filterfrm.res seems to break down the things... I'll take a look asap

jacopo-chevallard commented 7 years ago

How many points do you have in the new MIRI filter curves?

kevinhainline commented 7 years ago

The MIRI filter curves have 2-3000 points. I can cut them down to smaller versions and try, if you think that would work.

jacopo-chevallard commented 7 years ago

I think it's worth trying, maybe resampling them to < 1000 points and see if this solves

kevinhainline commented 7 years ago

So, I went and just used three filters:

% ./add_filters
 Filter response functions in (formatted) file = filterfrm.miri.cut.small.res
 Normalize response functions to area = 1 (y or [n]) ? n
   1 MIRI F560W                                                         399
   2 MIRI F770W                                                         449
   3 MIRI F1000W                                                        399

 Write binary file (y or [n]) ? y
 Enter output (binary) file name = FILTERBIN.RES
 Filter index in file: filters.log
STOP Binary file written.

Here are the filter files:

filter_files.zip

And here is what happens when trying to use this filter file:

% % docker run --rm -it -v /Users/knh/Desktop/NIRCam/BEAGLE/BEAGLE-general-master:/BEAGLE_virtual_workdir --env-file env.list beagletool/beagle:0.8.2 --parameter-file /BEAGLE_virtual_workdir/params/BEAGLE_mock_Stacey.param --mock

 Reading Filter File: /BEAGLE_virtual_workdir/filters/FILTERBIN.RES
   3 filters defined, out of 500                                maximum     ...done
 ---> fixed                         sfh_type                                   0
 ---> gridded                       metallicity                                0
 ---> gridded                       mass                                       0
 ---> dependent                     sfr                                        0
 ---> gridded                       redshift                                   0
 ---> fixed                         formation_redshift                         0
 ---> dependent                     nebular_logU                               0
 ---> fixed                         nebular_xi                                 0
 ---> dependent                     nebular_Z                                  0
 ---> fixed                         attenuation_type                           0
 ---> fixed                         tauV_eff                                   0
 ---> fixed                         mu                                         0
 n_fitted:            0
 --- LINEAR:  X0 =  6.020E+04 is outside X range --- 9.000E+02 6.010E+04      2362
 ---   Error reported only once. It may occur more than once. ---

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7F9A387F1E08
#1  0x7F9A387F0F90
#2  0x7F9A37F2349F
#3  0x4B6091 in sort2_ at sort2.f:13
#4  0x4B4E5B in build_filter_array_ at filter_n.f:189
#5  0x4B520F in filtr_master_ at filter_n.f:61
#6  0x4B566E in filtr_master_ at filter_n.f:17
#7  0x42F97C in __galaxy_sed_MOD_compute_sed at galaxy_SED.f90:486 (discriminator 14)
#8  0x406DC8 in MAIN__ at BEAGLE.f90:462

And I get the same segmentation fault. I am going to try this with one of the original NIRCam filters and see what happens.

kevinhainline commented 7 years ago

Ok, perhaps I'm doing something very wrong. If I go and take just the F444W filter:

% ./add_filters
 Filter response functions in (formatted) file = filterfrm.nircam.small_two.res
 Normalize response functions to area = 1 (y or [n]) ? n
   1 NIRCam F444W                                                      1452

 Write binary file (y or [n]) ? y
 Enter output (binary) file name = FILTERBIN.RES
 Filter index in file: filters.log
STOP Binary file written.

...and use it to create FILTERBIN.RES, and then update the filter file and the parameter file to reflect this:

# It contains the filters to be used when calculating only photometric models

# The possible units that can be used are: Jy, milliJy, microJy, nanoJy
# Alternatively one can pass a conversion factor to convert the fluxes in the
# catalogue into [erg s^-1 cm^-2 Hz^-1] -----> units:value:<conversion factor>
units:microJy

object_ID:colName:ID
#redshift:colName:redshift
#mass:colName:mass

index:1          min_rel_err:0.02       flux:colName:F444W              fluxerr:colName:F444W_err   label:F444W

I end up with this:

% docker run --rm -it -v /Users/knh/Desktop/NIRCam/BEAGLE/BEAGLE-general-master:/BEAGLE_virtual_workdir --env-file env.list beagletool/beagle:0.8.2 --parameter-file /BEAGLE_virtual_workdir/params/BEAGLE_mock_Stacey.param --mock

 Reading Filter File: /BEAGLE_virtual_workdir/filters/FILTERBIN.RES
   1 filters defined, out of 500                                maximum     ...done
 ---> fixed                         sfh_type                                   0
 ---> gridded                       metallicity                                0
 ---> gridded                       mass                                       0
 ---> dependent                     sfr                                        0
 ---> gridded                       redshift                                   0
 ---> fixed                         formation_redshift                         0
 ---> dependent                     nebular_logU                               0
 ---> fixed                         nebular_xi                                 0
 ---> dependent                     nebular_Z                                  0
 ---> fixed                         attenuation_type                           0
 ---> fixed                         tauV_eff                                   0
 ---> fixed                         mu                                         0
 n_fitted:            0

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7F03521B0E08
#1  0x7F03521AFF90
#2  0x7F03518E249F
#3  0x4B6091 in sort2_ at sort2.f:13
#4  0x4B4E5B in build_filter_array_ at filter_n.f:189
#5  0x4B520F in filtr_master_ at filter_n.f:61
#6  0x4B566E in filtr_master_ at filter_n.f:17
#7  0x42F97C in __galaxy_sed_MOD_compute_sed at galaxy_SED.f90:486 (discriminator 14)
#8  0x406DC8 in MAIN__ at BEAGLE.f90:462

The same line worked when I used the full FILTERBIN.RES file from which F444W was taken. So it's not just the MIRI filters.

camipacifici commented 7 years ago

Hi Kevin,

I believe the code needs at least a standard optical filter to compute all the magnitudes. Can you please try using a filter file that includes the original filters down to at least SDSS (I believe SDSS z-band is number 119) and then the new filters you want to add?

Best wishes,

Cami

kevinhainline commented 7 years ago

So, if I go and add in the filters out to 119 (the SDSS z filter), and after that I add in some NIRCam and MIRI filters, I still get a segmentation fault. Even if I just add in one NIRCam filter, I get the segmentation fault:

% docker run --rm -it -v /Users/knh/Desktop/NIRCam/BEAGLE/BEAGLE-general-master:/BEAGLE_virtual_workdir --env-file env.list beagletool/beagle:0.8.2 --parameter-file /BEAGLE_virtual_workdir/params/BEAGLE_mock_Stacey.param --mock

 Reading Filter File: /BEAGLE_virtual_workdir/filters/FILTERBIN.RES
 120 filters defined, out of 500                                maximum     ...done
 ---> fixed                         sfh_type                                   0
 ---> gridded                       metallicity                                0
 ---> gridded                       mass                                       0
 ---> dependent                     sfr                                        0
 ---> gridded                       redshift                                   0
 ---> fixed                         formation_redshift                         0
 ---> dependent                     nebular_logU                               0
 ---> fixed                         nebular_xi                                 0
 ---> dependent                     nebular_Z                                  0
 ---> fixed                         attenuation_type                           0
 ---> fixed                         tauV_eff                                   0
 ---> fixed                         mu                                         0
 n_fitted:            0

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7F97FC1C8E08
#1  0x7F97FC1C7F90
#2  0x7F97FB8FA49F
#3  0x4B6091 in sort2_ at sort2.f:13
#4  0x4B4E5B in build_filter_array_ at filter_n.f:189
#5  0x4B520F in filtr_master_ at filter_n.f:61
#6  0x4B566E in filtr_master_ at filter_n.f:17
#7  0x42F97C in __galaxy_sed_MOD_compute_sed at galaxy_SED.f90:486 (discriminator 14)
#8  0x406DC8 in MAIN__ at BEAGLE.f90:462
jacopo-chevallard commented 7 years ago

@kevinhainline @camipacifici the error message that you were getting was quite confusing, and it took me some time to figure it out, but the problem is that you should always add filters at the end of the filterfrm.res file provided in this repository (here), and not creating a new filterfrm.res file (this point was clear in the manual, less on the wiki, that I've now modified to clarify this point).

Kevin, we should rather work on the segfault error that you were getting in the first place, and make the addition of MIRI curves at the of filterfrm.res work

jacopo-chevallard commented 7 years ago

@kevinhainline @camipacifici Closing this, I assume that the above solution has solved your issues. Feel free to re-open if not!