from astropy.coordinates import SkyCoord from astropy.coordinates import ICRS, Galactic, FK4, FK5 from astropy.coordinates import Angle, Latitude, Longitude import astropy.units as u class FloatConverter: regex = '[-?\d\.\d]+' def to_python(self, value): return float(value) def to_url(self, value): return '{}'.format(value) def make_source_name(key, ra, dec): """ Makes source name in format JHHMMSS.s+/-DDMMSS based on input RA and Dec. """ try: c = SkyCoord(ra, dec, frame=FK5(), unit="deg") str1 = c.to_string('hmsdms',alwayssign=False,pad=False,precision=1).split() str2 = c.to_string('hmsdms',alwayssign=True,pad=False,precision=0).split() name = key+" J%s%s" % (str1[0].replace('h','').replace('m','').replace('s',''), str2[1].replace('d','').replace('m','').replace('s','')) return(name) except: return('None') status_code = {0:"No error", 1:'SRG arXiv: User is not authenticated', 2:'SRG arXiv: User has no user profile', 3:'SRG arXiv: User has no appropriate group to access this page',} def srg_group_auth(user, group): if not user.is_authenticated: return 1 try: user_profile=user.profile except: return 2 if not user.groups.filter(name=group).exists(): return 3 return 0