[docs]classSBDBquery:"""Small-Body Database Query for retrieving various properties of a small body. Usefull for retrieving names and masses in conjunction with the MPC module. """def__init__(self,MPCcode:Union[str,int],*args,**kwargs)->None:"""Create a Small-Body Database Query Additional parameters are available through args and kwards, see: https://astroquery.readthedocs.io/en/latest/jplsbdb/jplsbdb.html Parameters ---------- MPCcode : Union[str, int] MPC code for the object. """self.MPCcode=MPCcodeself.query=astroquerySBDB.query(MPCcode,phys=True,*args,**kwargs)def__str__(self)->str:returnastroquerySBDB.schematic(self.query)def__getitem__(self,index)->Any:# makes the instance directly subscriptable, i.e.: query["phys_par"]returndict(self.query[index])@propertydefname(self):"""Short name in the format: `MPC NAME DESIGNATION`"""returnself.query["object"]["fullname"]@propertydefshortname(self):"""Short name in the format: `MPC NAME`"""returnself.query["object"]["shortname"]@propertydefspkid(self):"""Returns the JPL SPKID, the related codes_300_spkid method returns a modified ID for the Tudat standard kernel"""returnself.query["object"]["spkid"]@propertydefcodes_300_spkid(self):"""Returns spice kernel number for the codes_300ast_20100725.bsp spice kernel. Some objects may return a name instead of a number. These are objects specifically specified by name in the codes_300ast_20100725.bsp kernel. See https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/asteroids/aa_summaries.txt for a list of exceptions """spkid=self.spkid[0]+self.spkid[2:]ifspkid=="2000001":return"Ceres"elifspkid=="2000004":return"Vesta"elifspkid=="2000021":return"Lutetia"elifspkid=="2000216":return"Kleopatra"elifspkid=="2000433":return"Eros"else:returnspkid@propertydefgravitational_parameter(self):"""Returns the gravitational parameter for the small body if available"""try:res=self.query["phys_par"]["GM"].to(u.meter**3/u.second**2)returnres.valueexceptExceptionas_:raiseValueError(f"Gravitational parameter is not available for object {self.name}")@propertydefobject_info(self):"""Returns info about the object, including its designation and orbit class"""returnself.query["object"]@propertydefobject_classification(self):"""Returns the orbit class of the object for example Amor Group for Eros"""returnself.object_info["orbit_class"]["name"]@propertydefdiameter(self):"""Returns diameter of the small body if available"""try:res=self.query["phys_par"]["diameter"].to(u.meter)returnres.valueexceptExceptionas_:raiseValueError(f"Gravitational parameter is not available for object {self.name}")
[docs]defestimated_spherical_mass(self,density:float):"""Calculate a very simple mass by estimating the object's mass using a given density. Will raise an error if the body's diameter is not available on SBDB. Parameters ---------- density : float Density of the object in `kg m^-3` Returns ------- float Simplified estimation for the object's mass """volume=(math.pi/6)*self.diameter**3mass=volume*densityreturnmass
[docs]defestimated_spherical_gravitational_parameter(self,density:float):"""Calculate a very simple gravitational parameter by estimating the object's mass using a given density. Will raise an error if the body's diameter is not available on SBDB. Parameters ---------- density : float Density of the object in `kg m^-3` Returns ------- float Simplified estimation for the object's gravitational parameter """returnGRAVITATIONAL_CONSTANT*self.estimated_spherical_mass(density)