Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snow_white GaiaID str fix #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions python/astra/pipelines/snow_white/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ def snow_white(
log_H=np.array(tl[u'logg_H']).astype(float)
eT_H=np.array(tl[u'eteff_H']).astype(float)
elog_H=np.array(tl[u'elogg_H']).astype(float)
if spectrum.source.gaia_dr3_source_id in sourceID: #if there is a photometric solution use that as starting point
first_T=T_H[sourceID==spectrum.source.gaia_dr3_source_id][0]
first_g=log_H[sourceID==spectrum.source.gaia_dr3_source_id][0]*100
GaiaID=str(spectrum.source.gaia_dr3_source_id)
if GaiaID in sourceID: #if there is a photometric solution use that as starting point
first_T=T_H[sourceID==GaiaID][0]
first_g=log_H[sourceID==GaiaID][0]*100
initial=1
if first_T > 80000:
first_T=80000
Expand Down Expand Up @@ -201,12 +202,12 @@ def snow_white(
if first_T <=13000.:
tmp_Tg,tmp_chi= grid_param[grid_param[:,0]>13000.], grid_chi[grid_param[:,0]>13000.]
second_T= tmp_Tg[tmp_chi==np.min(tmp_chi)][0][0]
fit_params['teff'] = lmfit.Parameter(name="teff",value=second_T,min=13000,max=80000)
fit_params['teff'] = lmfit.Parameter(name="teff",value=second_T,min=12000,max=80000)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand fixing the string comparison bug we discussed by email, but I’m confused by the logic of splitting up to 12,000 K in one optimisation and then 14,000 K in another. What am I missing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Andy,
Unless I messed up I did not change where the split happens. I still look for a secondary solution starting below 13000 if the first one was hotter and above 13000 if the first solution was colder.

What I did was make the maximum value in the fit less a of strict wall. So yes I am looking for a solution above 13000 so I start the fit from the best initial value above 13000, but the fit may still only converge below 13000 so I am now giving some margin to go below 13000 during the fit so we don't just get a bunch of exactly Teff=13000K for fits that would converge just below it.

Similarly I expanded the maximum limit to 14000 if I am looking for a second solution starting below 13000.


elif first_T >13000.:
tmp_Tg,tmp_chi= grid_param[grid_param[:,0]<13000.], grid_chi[grid_param[:,0]<13000.]
second_T= tmp_Tg[tmp_chi==np.min(tmp_chi)][0][0]
fit_params['teff'] = lmfit.Parameter(name="teff",value=second_T,min=3000,max=13000)
fit_params['teff'] = lmfit.Parameter(name="teff",value=second_T,min=3000,max=14000)

if second_T>=16000 and second_T<=40000:
line_crop = np.loadtxt(os.path.join(PIPELINE_DATA_DIR, 'line_crop.dat'),skiprows=1)
Expand Down