skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.38k stars 208 forks source link

Comet object apparent magnitude calculation #964

Open jurezakrajsek opened 1 month ago

jurezakrajsek commented 1 month ago

Is there already an available function that would calculate the comet apparent magnitude at a given time? I could not find it there for I have written my own function, maybe it would be of interest to add it to the SkyField in the future?

def obj_magnitude(self):
    r = self.comet_obj.distance()
    ra, dec, delta = self.observed_comet.radec()
    mag_g = self.row.magnitude_g
    mag_k = self.row.magnitude_k

    if self.num > 1:
        return np.asarray(
            [mag_g + 5 * math.log10(di) + 2.5 * mag_k * math.log10(ri) for ri, di in zip(r.au, delta.au)])
    else:
        return mag_g + 5 * math.log10(delta.au) + 2.5 * mag_k * math.log10(r.au)