Running examples in ‘ProFit-Ex.R’ failed
The error most likely occurred in:

> ### Name: profitSetupData
> ### Title: Setup ProFit Data
> ### Aliases: profitSetupData
> ### Keywords: data
> 
> ### ** Examples
> 
> # Load ProFit example data
> 
> # There are 2 data source options: KiDS or SDSS (the galaxies are the same)
> 
> datasource='KiDS' 
> 
> # Now we can extract out the example files we have available for fitting by checking the
> # contents of the directory containing the example FITS files:
> 
> data('ExampleInit')
> ExampleFiles=list.files(system.file("extdata",datasource,package="ProFit"))
> ExampleIDs=unlist(strsplit(ExampleFiles[grep('fitim',ExampleFiles)],'fitim.fits'))
> print(ExampleIDs)
 [1] "G265911" "G265940" "G266033" "G266035" "G266662" "G267199" "G267489"
 [8] "G267525" "G278109" "G279148"
> 
> # There are 10 example galaxies included. Here we run example 1:
> 
> useID=ExampleIDs[1]
> 
> image = readFITS(system.file("extdata", paste(datasource,'/',useID,'fitim.fits',sep=''),
+ package="ProFit"))$imDat
> sigma = readFITS(system.file("extdata", paste(datasource,'/',useID,'sigma.fits',sep=''),
+ package="ProFit"))$imDat
> segim = readFITS(system.file("extdata", paste(datasource,'/',useID,'segim.fits',sep=''),
+ package="ProFit"))$imDat
> psf = readFITS(system.file("extdata", paste(datasource,'/',useID,'psfim.fits',sep=''),
+ package="ProFit"))$imDat
> 
> # Very rough model (not meant to look too good yet):
> 
> useIDnum=as.integer(strsplit(useID,'G')[[1]][2])
> useloc=which(ExampleInit$CATAID==useIDnum)
> 
> # For our initial model we treat component 1 as the putitive bulge and componet 2 as
> # the putitive disk. We are going to attempt a fit where the disk is forced to have
> # nser=1 and the bulge has an axial ratio of 1.
> 
> modellist=list(
+   sersic=list(
+     xcen= c(dim(image)[1]/2, dim(image)[1]/2),
+     ycen= c(dim(image)[2]/2, dim(image)[2]/2),
+     mag= c(ExampleInit$sersic.mag1[useloc], ExampleInit$sersic.mag2[useloc]),
+     re= c(ExampleInit$sersic.re1[useloc], ExampleInit$sersic.re2[useloc])*
+       if(datasource=='KiDS'){1}else{0.2/0.339},
+     nser= c(ExampleInit$sersic.nser1[useloc], 1),  #Disk is initially nser=1
+     ang= c(ExampleInit$sersic.ang2[useloc], ExampleInit$sersic.ang2[useloc]),
+     axrat= c(1, ExampleInit$sersic.axrat2[useloc]),  #Bulge is initially axrat=1
+     box=c(0, 0)
+   )
+ )
> 
> # The pure model (no PSF):
> magimage(profitMakeModel(modellist,dim=dim(image)))
> 
> # The original image:
> magimage(image)
> 
> # The convolved model (with PSF):
> magimage(profitMakeModel(modellist,dim=dim(image),psf=psf))
> 
> # What should we be fitting:
> 
> tofit=list(
+   sersic=list(
+     xcen= c(TRUE,NA), #We fit for xcen and tie the two together
+     ycen= c(TRUE,NA), #We fit for ycen and tie the two together
+     mag= c(TRUE,TRUE), #Fit for both
+     re= c(TRUE,TRUE), #Fit for both
+     nser= c(TRUE,FALSE), #Fit for bulge
+     ang= c(FALSE,TRUE), #Fit for disk
+     axrat= c(FALSE,TRUE), #Fit for disk
+     box= c(FALSE,FALSE) #Fit for neither
+   )
+ )
> 
> # What parameters should be fitted in log space:
> 
> tolog=list(
+   sersic=list(
+     xcen= c(FALSE,FALSE),
+     ycen= c(FALSE,FALSE),
+     mag= c(FALSE,FALSE),
+     re= c(TRUE,TRUE), #re is best fit in log space
+     nser= c(TRUE,TRUE), #nser is best fit in log space
+     ang= c(FALSE,FALSE),
+     axrat= c(TRUE,TRUE), #axrat is best fit in log space
+     box= c(FALSE,FALSE)
+   )
+ )
> 
> # Setup the minimal data structure we need for likelihood.
> 
> Data=profitSetupData(image=image, sigma=sigma, segim=segim, psf=psf,
+ modellist=modellist, tofit=tofit, tolog=tolog, magzero=0, algo.func='optim', verbose=TRUE)
> 
> # Finally, calcualte the likelihood and make a plot:
> 
> profitLikeModel(parm=Data$init, Data=Data, makeplots=TRUE)
[1] "Summary of used sample:"
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
-76.6588  -0.4123   0.4049   0.2498   1.2617  23.7657 
[1] "sd / 1-sig / 2-sig range:"
[1] 3.558640 1.280227 4.606598
[1] "Using 16777 out of 16777"
 sersic.xcen1  sersic.ycen1   sersic.mag1   sersic.mag2    sersic.re1 
   8.4500e+01    9.3500e+01    1.6832e+01    1.6832e+01    8.4864e-01 
   sersic.re2  sersic.nser1   sersic.ang2 sersic.axrat2               
   1.1497e+00    6.4124e-01    1.4082e+02   -3.1060e-01   -1.2217e+05 
> 
> # If you're brave and your software/drivers are configured correctly, try benchmarking
> # with OpenCL and OpenMP:
> openclenvs = profitGetOpenCLEnvs(make.envs = TRUE)
> 
> Data=profitSetupData(image=image, sigma=sigma, segim=segim, psf=psf,
+ modellist=modellist, tofit=tofit, tolog=tolog, magzero=0, algo.func='optim', verbose=TRUE,
+ nbenchmark = 5L, benchconvmethods = profitAvailableConvolvers(),
+ benchintmethods = profitAvailableIntegrators(), benchopenclenvs = openclenvs,
+ printbenchmark = TRUE, omp_threads=4)
    name env_name version                                        dev_name
1  brute     <NA>      NA                                            <NA>
2 opencl    Apple     1.2 Intel(R) Xeon(R) CPU           E5462  @ 2.80GHz
3 opencl    Apple     1.2                                  GeForce GT 630
  tinms.mean_single tinms.mean_double
1                NA               8.2
2                NA              47.4
3                NA                NA
[1] "Best integrator: 'brute' device: 'NA', t=[8.20e+00 ms]"
    name env_name version                                        dev_name
1  brute     <NA>      NA                                            <NA>
2 opencl    Apple     1.2 Intel(R) Xeon(R) CPU           E5462  @ 2.80GHz
3 opencl    Apple     1.2                                  GeForce GT 630
4   fftw     <NA>      NA                                            <NA>
  tinms.mean_single tinms.mean_double
1                NA               5.4
2                NA              12.0
3                NA                NA
4                NA              12.8
[1] "Best convolver: 'brute' device: 'NA', t=[5.40e+00 ms]"
> 
> profitLikeModel(parm=Data$init, Data=Data, makeplots=TRUE, plotchisq=TRUE)
 sersic.xcen1  sersic.ycen1   sersic.mag1   sersic.mag2    sersic.re1 
   8.4500e+01    9.3500e+01    1.6832e+01    1.6832e+01    8.4864e-01 
   sersic.re2  sersic.nser1   sersic.ang2 sersic.axrat2               
   1.1497e+00    6.4124e-01    1.4082e+02   -3.1060e-01   -1.2217e+05 
> 
> 
> 
> ### * <FOOTER>
> ###
> cleanEx()
> options(digits = 7L)
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
Time elapsed:  11.439 1.364 11.2 0 0 
> grDevices::dev.off()
null device 
          1 
> ###
> ### Local variables: ***
> ### mode: outline-minor ***
> ### outline-regexp: "\\(> \\)?### [*]+" ***
> ### End: ***
> quit('no')

 *** caught segfault ***
address 0x60, cause 'memory not mapped'
An irrecoverable exception occurred. R is aborting now ...