def get_dso_list(catalog=None, kind=None, constellation=None, uptovmag=None, limit=None): params = dict() if (catalog is not None) and (catalog in ONGC_CATALOGS_ABREVS_FROM_NAMES.keys()): params.update({'catalog': ONGC_CATALOGS_ABREVS_FROM_NAMES[catalog]}) if (kind is not None) and (kind in ONGC_TYPES_ABREVS_FROM_NAMES.keys()): params.update({'type': ONGC_TYPES_ABREVS_FROM_NAMES[kind]}) if (constellation is not None) and (constellation in CONSTELLATIONS_ABBREV_FROM_LATIN.keys()): params.update( {'constellation': CONSTELLATIONS_ABBREV_FROM_LATIN[constellation]}) if uptovmag is not None and is_float(uptovmag): params.update({'uptovmag': float(uptovmag)}) return [ obj for obj in listObjects(**params)[0:limit] if obj.getType() != "Duplicated record" ]
def test_dataIntegrity(self): allObjects = ongc.listObjects() for item in allObjects: self.assertIsInstance(item.getId(), int) self.assertNotEqual(item.getType(), '') if item.getType() != 'Nonexistent object': self.assertIsInstance(item.getCoords(), tuple) self.assertNotEqual(item.getDec(), '') self.assertNotEqual(item.getRA(), '') self.assertNotEqual(item.getConstellation(), '') self.assertIsInstance(item.getDimensions(), tuple) self.assertIsInstance(item.getMagnitudes(), tuple)
def search(out_file, **kwargs): """Search in the database for objects with given parameters.""" try: for r in ['minra', 'maxra']: if kwargs[r] is not None: pattern = re.compile(r'^(?:(\d{1,2}):(\d{1,2}):(\d{1,2}(?:\.\d{1,2})?))$') result = pattern.match(kwargs[r]) hms = [float(x) for x in result.groups()[0:3]] kwargs[r] = hms[0] * 15 + hms[1] * 1/4 + hms[2] * 1/240 for d in ['mindec', 'maxdec']: if kwargs[d] is not None: pattern = re.compile(r'^(?:([+-]?\d{1,2}):(\d{1,2}):(\d{1,2}(?:\.\d{1,2})?))$') result = pattern.match(kwargs[d]) dms = [float(x) for x in result.groups()[0:3]] if dms[0] < 0: kwargs[d] = dms[0] + dms[1] * -1/60 + dms[2] * -1/3600 else: kwargs[d] = dms[0] + dms[1] * 1/60 + dms[2] * 1/3600 for v in ['type', 'constellation']: if kwargs[v] is not None: kwargs[v] = [x.strip() for x in kwargs[v].split(',')] object_list = ongc.listObjects( **{k: v for k, v in kwargs.items() if (v is not None and v is not False)}) if len(object_list) == 0: click.secho('\nNo objects found with such parameters!', bold=True) return if out_file is not None: out_file.write('\n'.join(str(dso) for dso in object_list)) out_file.flush() else: if len(object_list) > 20: if click.confirm(click.style('WARNING: ', fg='yellow', bold=True) + 'the result list is long. Do you want to see it via a pager?'): click.echo_via_pager('\n'.join(str(dso) for dso in object_list)) return for dso in object_list: click.echo(str(dso)) except Exception as e: click.echo(f'{click.style("ERROR:", fg="red", bold=True)} {e}')
def get_dso_list(): return [ obj for obj in listObjects(catalog='M') if obj.getType() != "Duplicated record" and obj.getType() != "Nonexistent object" ]