INNER CODE UNIT · Python

_add_astroNN_ages

jobovy/gaia_tools · gaia_tools/load/__init__.py:528

def _add_astroNN_ages(data,astroNNAgesdata,rowmatched=False):
    fields_to_append= ['astroNN_age','astroNN_age_total_std',
                       'astroNN_age_predictive_std','astroNN_age_model_std']
    if True:
        # Faster way to join structured arrays (see https://stackoverflow.com/questions/5355744/numpy-joining-structured-arrays)
        newdtype= data.dtype.descr+\
            [(f,'<f8') for f in fields_to_append]
        newdata= numpy.empty(len(data),dtype=newdtype)
        for name in data.dtype.names:
            newdata[name]= data[name]
        for f in fields_to_append:
            if rowmatched:
                newdata[f]= astroNNAgesdata[f]
            else:
                newdata[f]= numpy.zeros(len(data))-9999.
        data= newdata
    else:
        # This, for some reason, is the slow part (see numpy/numpy#7811

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…