Skip to content

Commit

Permalink
Merge pull request #49 from bosscha/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
bosscha authored Jun 2, 2023
2 parents af5c117 + 3db03db commit ef2c323
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 deletions.
5 changes: 4 additions & 1 deletion scripts/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ function reprocess(meta)
if haskey(row, :mclm) mextra.mcl= Int(floor(row.mclm)) else mextra.mcl= Int(floor(row.mcl)) end
if haskey(row, :mneim) mextra.mnei= Int(floor(row.mneim)) else mextra.mnei= Int(floor(row.mnei)) end

debug_red(mextra)
#smextra.wvel= 8.0
debug_red("Weights : $(mextra.w3d) $(mextra.wvel) $(mextra.whrd) ")


extra(mextra, optim)
push!(dfp, [mextra.votname])
CSV.write(progressfile, dfp, delim=";")
Expand Down
2 changes: 1 addition & 1 deletion src/GaiaClustering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using PyCall , PyPlot
using VoronoiCells
import GeometryBasics as gb

VERSION= "1.7.7"
VERSION= "1.7.8"

## include all the types
include("types.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ function get_data(m::GaiaClustering.meta)

if m.zpt=="yes"
zoff= true
println("## Will apply Zero Point offset correction on parallax...")
println("## Applying Zero Point offset correction on parallax...")
else
zoff= false
end
Expand Down
37 changes: 34 additions & 3 deletions src/isochrones.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ function dist_cmd2iso(df, iso, wgt)
diso[1,:] = iso.Gaia_BPmRP_EDR3
diso[2,:] = iso.Gaia_G_EDR3

# debug_red("dist_cmd ...........")

kdtree = KDTree(diso; leafsize = 10)

npts= length(df.G)
Expand All @@ -138,9 +140,12 @@ function dist_cmd2iso(df, iso, wgt)
pts[2,:] = df.G

idxs, dists = knn(kdtree, pts, 1, true)

dists = dists .* wgt
total= sum(dists)

# debug_red("dists total ... $total")

return(total)
end
################################################################################
Expand Down Expand Up @@ -224,14 +229,26 @@ function update_nan_oc(df)
## absolute magnitude
df.G = df.gbar0 .+ 5 .- 5log10.(df.distance)


return(df)
end
##########################################
### get solar mass from isochrone
###
function get_star_mass(df, iso)
global n
println("### add star mass...")
n= length(iso.Gaia_G_EDR3)

n= 0
try
# debug_red(iso)
global n= length(iso.Gaia_G_EDR3)
debug_red("n: $n")
catch e
println("### Warning : no valid Gaia_G_EDR3 field in solution...")
return(0)
end

diso= zeros(2,n)
diso[1,:] = iso.Gaia_BPmRP_EDR3
diso[2,:] = iso.Gaia_G_EDR3
Expand Down Expand Up @@ -259,6 +276,8 @@ function perform_isochrone_fitting(df, isomodeldir)
df= update_mag(df,false)
oc= filter(:G => G -> !any(f -> f(G), (ismissing, isnothing, isnan)), df)

noc= nrow(oc)
debug_red("...length $noc")

## reading isochrone model
if isomodeldir == ""
Expand All @@ -280,10 +299,22 @@ function perform_isochrone_fitting(df, isomodeldir)

df= update_nan_oc(df)

# debug_red(first(iso))
df= get_star_mass(df, iso)

feh_gaia= median(df.mh)
if typeof(df) == Int64 ## no solution...
println("### Warning: no solution...")
feh_gaia= -99
else
feh_gaia= median(df.mh)
end

return(df , age, feh, feh_gaia, iso)
end
## counting valid row in a df...
function counting_valid(df)
dft= filter(:mh => mh -> !any(f -> f(mh), (ismissing, isnothing, isnan)), df)

nvalid= length(dft.mh)

return(nvalid)
end
7 changes: 5 additions & 2 deletions src/stellarcluster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,11 @@ function cycle_extraction_optim(df::GaiaClustering.Df, dfcart::GaiaClustering.Df
println("## label $labelmax written as an oc solution...")

### isochrone fitting...
minptsiso= 10 # minimum pts to fit..
if m.iso == "yes" && count(!isnan, oc.ag) > minptsiso
minptsiso= 10 # minimum pts to fit.
nvalid= counting_valid(oc)
debug_red("nvalid : $nvalid")

if m.iso == "yes" && count(!isnan, oc.ag) > minptsiso && nvalid > minptsiso
println("## Performing isochrone fitting on the solution...")
debug_red(count(!isnan, oc.ag))
oc, age, feh, feh_gaia, iso= perform_isochrone_fitting(oc, m.isomodel)
Expand Down

0 comments on commit ef2c323

Please sign in to comment.