Skip to content

Commit a953890

Browse files
committed
alf v2.0
1 parent 06ad980 commit a953890

3 files changed

Lines changed: 53 additions & 50 deletions

File tree

src/alf.f90

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROGRAM ALF
3838
!length of chain burn-in
3939
INTEGER, PARAMETER :: nburn=10000
4040
!number of walkers
41-
INTEGER, PARAMETER :: nwalkers=512 !1024
41+
INTEGER, PARAMETER :: nwalkers=1024
4242
!save the chain outputs to file
4343
INTEGER, PARAMETER :: print_mcmc=0
4444

@@ -82,31 +82,27 @@ PROGRAM ALF
8282
!0=full, 1=simple, 2=super-simple. See sfvars for details
8383
fit_type = 0
8484
!type of IMF to fit
85-
!0=single power-law, 1=double power-law, 2=power-law+cutoff, 3=2pl+ct
85+
!0=1PL, 1=2PL, 2=1PL+cutoff, 3=2PL+cutoff, 4=5-pt PL
8686
imf_type = 1
8787
!are the data in the original observed frame?
88-
observed_frame = 0
88+
observed_frame = 1
8989

9090
!dont fit transmission function in cases where the input
9191
!spectrum has already been de-redshifted to ~0.0
9292
IF (observed_frame.EQ.0) THEN
9393
fit_trans = 0
9494
prhi%logtrans = -5.0
95-
prhi%logsky = -5.0
95+
prhi%logsky = -5.0
9696
ELSE
9797
fit_trans = 1
98+
!extra smoothing to the transmission spectrum
99+
!if the input data has been smoothed by a gaussian
100+
!in velocity space, set the parameter below to that extra smoothing
101+
smooth_trans = 0.0
98102
ENDIF
99103

100-
!extra smoothing to the transmission spectrum
101-
!if the input data has been smoothed by a gaussian
102-
!in velocity space, set the parameter below to that extra smoothing
103-
smooth_trans = 0.0
104-
105-
!limit the range of [Z/H] to be very small
106-
!prlo%zh = -0.01
107-
!prhi%zh = 0.01
108104
!set low upper prior limits to kill off these parameters
109-
!prhi%logm7g = -5.0
105+
prhi%logm7g = -5.0
110106
!prhi%loghot = -5.0
111107
!prhi%logtrans = -5.0
112108
!prhi%logfy = -5.0
@@ -298,7 +294,6 @@ PROGRAM ALF
298294
write(*,*) msto
299295
CALL GETMODEL(tpos,mspecmw,mw=1) !get spectrum for MW IMF
300296
CALL GETM2L(msto,lam,mspecmw,tpos,m2lmw,mw=1) !compute M/L_MW
301-
!CALL GETM2L(msto,lam,10**sspgrid%logfkrpa(:,nage,nzmet-1),tpos,m2lmw,mw=1)
302297
write(*,'(2F7.2)') m2lmw(1:2)
303298
CALL GETMODEL(tpos,mspec)
304299
CALL GETM2L(msto,lam,mspec,tpos,m2l) ! compute M/L

src/alf_vars.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ MODULE ALF_VARS
201201
logfy=-4.0,sigma2=0.0,velz2=0.0,logm7g=-4.0,hotteff=20.0,&
202202
loghot=-4.0,fy_logage=0.3,logtrans=-4.0,logemline_h=-4.0,&
203203
logemline_oiii=-4.0,logemline_sii=-4.0,logemline_ni=-4.0,&
204-
logemline_nii=-4.0,jitter=1.0,imf3=2.0,logsky=-4.0
204+
logemline_nii=-4.0,jitter=1.0,imf3=2.0,logsky=-4.0,imf4=0.0,&
205+
imf5=0.0
205206
REAL(DP) :: chi2=huge_number
206207
END TYPE PARAMS
207208

src/set_pinit_priors.f90

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@ SUBROUTINE SET_PINIT_PRIORS(pos,prlo,prhi,velz)
55
!that if the user defines a prior limit that is **different from
66
!the default parameter set**, then that value overrides the defaults below
77

8-
USE alf_vars; USE alf_utils, ONLY : myran
8+
USE alf_vars; USE alf_utils, ONLY : myran,str2arr
99
IMPLICIT NONE
1010

1111
TYPE(PARAMS), INTENT(inout) :: pos,prlo,prhi
12-
TYPE(PARAMS) :: test
12+
TYPE(PARAMS) :: test,tprlo,tprhi
13+
INTEGER :: i
1314
REAL(DP), OPTIONAL :: velz
14-
15+
REAL(DP), DIMENSION(npar) :: prloarr1=0.,prhiarr1=0.,tprloarr1=0.
16+
REAL(DP), DIMENSION(npar) :: testarr1=0.,posarr1=0.,tprhiarr1=0.
17+
1518
!---------------------------------------------------------------!
1619
!---------------------------------------------------------------!
1720

21+
tprlo = prlo
22+
tprhi = prhi
23+
24+
1825
!setup the first position
1926
pos%logage = myran()*0.4+0.6
2027
pos%zh = myran()*1.0-1.0
@@ -164,12 +171,12 @@ SUBROUTINE SET_PINIT_PRIORS(pos,prlo,prhi,velz)
164171
IF (prhi%teff.EQ.test%teff) prhi%teff = 50.0
165172
IF (prhi%imf1.EQ.test%imf1) prhi%imf1 = 3.5
166173
IF (imf_type.EQ.0.OR.imf_type.EQ.1.OR.imf_type.EQ.3) THEN
167-
IF (prhi%imf2.EQ.test%imf2) prhi%imf2 = 3.5
174+
IF (prhi%imf2.EQ.test%imf2) prhi%imf2 = 3.5
168175
ELSE IF (imf_type.EQ.2) THEN
169-
IF (prhi%imf2.EQ.test%imf2) prhi%imf2 = 0.5
176+
IF (prhi%imf2.EQ.test%imf2) prhi%imf2 = 0.5
170177
ENDIF
171-
IF (prhi%imf3.EQ.test%imf3) prhi%imf3 = 0.4
172-
IF (prhi%logfy.EQ.test%logfy) prhi%logfy = -0.7
178+
IF (prhi%imf3.EQ.test%imf3) prhi%imf3 = 0.4
179+
IF (prhi%logfy.EQ.test%logfy) prhi%logfy = -0.7
173180
IF (prhi%fy_logage.EQ.test%fy_logage) prhi%fy_logage = LOG10(3.0)
174181
IF (prhi%logm7g.EQ.test%logm7g) prhi%logm7g = -1.0
175182
IF (prhi%hotteff.EQ.test%hotteff) prhi%hotteff= 30.0
@@ -188,33 +195,33 @@ SUBROUTINE SET_PINIT_PRIORS(pos,prlo,prhi,velz)
188195
IF (prhi%logsky.EQ.test%logsky) prhi%logsky = 2.0
189196

190197

191-
!reset the initial parameters if the priors have been altered
192-
!this should be done for every parameter to ensure that the altered parameters
193-
!do not fall outside of the prior range. In practice only these params are
194-
!frequently altered.
195-
IF (prhi%logtrans.NE.test%logtrans.OR.prlo%logtrans.NE.test%logtrans) &
196-
pos%logtrans = myran()*(prhi%logtrans-prlo%logtrans)+prlo%logtrans
197-
IF (prhi%logsky.NE.test%logsky.OR.prlo%logsky.NE.test%logsky) &
198-
pos%logsky = myran()*(prhi%logsky-prlo%logsky)+prlo%logsky
199-
IF (prhi%logfy.NE.test%logfy.OR.prlo%logfy.NE.test%logfy) &
200-
pos%logfy = myran()*(prhi%logfy-prlo%logfy)+prlo%logfy
201-
IF (prhi%loghot.NE.test%loghot.OR.prlo%loghot.NE.test%loghot) &
202-
pos%loghot = myran()*(prhi%loghot-prlo%loghot)+prlo%loghot
203-
IF (prhi%logm7g.NE.test%logm7g.OR.prlo%logm7g.NE.test%logm7g) &
204-
pos%logm7g = myran()*(prhi%logm7g-prlo%logm7g)+prlo%logm7g
205-
IF (prhi%logemline_h.NE.test%logemline_h.OR.prlo%logemline_h.NE.test%logemline_h) &
206-
pos%logemline_h = myran()*(prhi%logemline_h-prlo%logemline_h)+prlo%logemline_h
207-
IF (prhi%logemline_oiii.NE.test%logemline_oiii.OR.prlo%logemline_oiii.NE.test%logemline_oiii) &
208-
pos%logemline_oiii = myran()*(prhi%logemline_oiii-prlo%logemline_oiii)+prlo%logemline_oiii
209-
IF (prhi%logemline_sii.NE.test%logemline_sii.OR.prlo%logemline_sii.NE.test%logemline_sii) &
210-
pos%logemline_sii = myran()*(prhi%logemline_sii-prlo%logemline_sii)+prlo%logemline_sii
211-
IF (prhi%logemline_ni.NE.test%logemline_ni.OR.prlo%logemline_ni.NE.test%logemline_ni) &
212-
pos%logemline_ni = myran()*(prhi%logemline_ni-prlo%logemline_ni)+prlo%logemline_ni
213-
IF (prhi%logemline_nii.NE.test%logemline_nii.OR.prlo%logemline_nii.NE.test%logemline_nii) &
214-
pos%logemline_nii = myran()*(prhi%logemline_nii-prlo%logemline_nii)+prlo%logemline_nii
215-
IF (prhi%zh.NE.test%zh.OR.prlo%zh.NE.test%zh) &
216-
pos%zh = myran()*(prhi%zh-prlo%zh)+prlo%zh
217-
IF (prhi%teff.NE.test%teff.OR.prlo%teff.NE.test%teff) &
218-
pos%teff = myran()*(prhi%teff-prlo%teff)+prlo%teff
198+
!--------------------------------------------------------------------------!
199+
!-------reset the initial parameters if the priors have been altered-------!
200+
!--------------------------------------------------------------------------!
201+
202+
!str->arr
203+
CALL STR2ARR(1,tprlo,tprloarr1)
204+
CALL STR2ARR(1,tprhi,tprhiarr1)
205+
CALL STR2ARR(1,prlo,prloarr1)
206+
CALL STR2ARR(1,prhi,prhiarr1)
207+
CALL STR2ARR(1,test,testarr1)
208+
CALL STR2ARR(1,pos,posarr1)
209+
210+
!test the priors and if the priors have been altered then
211+
!re-initialize the parameters within the prior range
212+
!NB: why not simply always initialize the starting position this way?
213+
DO i=3,npar
214+
IF (prhiarr1(i).LE.prloarr1(i)) THEN
215+
WRITE(*,*) 'SET_PINIT_PRIORS ERROR: prhi < prlo!', i
216+
STOP
217+
ENDIF
218+
IF (tprhiarr1(i).NE.testarr1(i).OR.tprloarr1(i).NE.testarr1(i)) THEN
219+
posarr1(i) = myran()*(prhiarr1(i)-prloarr1(i)) + prloarr1(i)
220+
ENDIF
221+
ENDDO
222+
223+
!arr->str
224+
CALL STR2ARR(2,pos,posarr1)
225+
219226

220227
END SUBROUTINE SET_PINIT_PRIORS

0 commit comments

Comments
 (0)