Beispiel #1
0
 public void TestQueryAround()
 {
     var simbadClient = new SimbadClient();
     var objects      = simbadClient.QueryAround(
         new Objects.RaDecCoordinate(rightAscension: 20, declination: 10),
         radiusInDegrees: 1.5f);
 }
Beispiel #2
0
        public async Task <bool> ExecuteRegexCommandAsync(ReceivedMessage receivedMessage, Match regexMatch)
        {
            if (regexMatch.Groups["ObjectName"].Success)
            {
                var astronomicalObjectName = regexMatch.Groups["ObjectName"].Value;
                var simbadClient           = new SimbadClient();
                var objectResolvedBySimbad = simbadClient.FindObjectByName(astronomicalObjectName);

                if (objectResolvedBySimbad == null)
                {
                    await receivedMessage.Channel.SendMessageAsync($"No object with name {astronomicalObjectName} could be found on simbad!").ConfigureAwait(false);

                    return(true);
                }

                if (objectResolvedBySimbad.RaDecCoordinate == null)
                {
                    await receivedMessage.Channel.SendMessageAsync($"The object was found, but no Ra / Dec coordinates are known for the object!").ConfigureAwait(false);

                    return(true);
                }

                await receivedMessage.Channel.SendMessageAsync("Getting the image from the deep sky survey (DSS) server, one moment...\r\n(The larger the FOV, the longer it takes)").ConfigureAwait(false);

                var arcminutesSize =
                    Math.Max(objectResolvedBySimbad.AngularDimensions != null
                        ? Math.Min(objectResolvedBySimbad.AngularDimensions.MajorAxis * FACTOR_ANGULARSIZE_ARCMINUTES, MAX_ANGULARSIZE_ARCMINUTES)
                        : DEFAULT_ANGULARSIZE_ARCMINUTES,
                             MIN_ANGULARSIZE_ARCMINUTES);

                var image = DeepSkySurvey.DeepSkySurveyClient.GetImage(
                    Convert.ToSingle(objectResolvedBySimbad.RaDecCoordinate.RightAscension),
                    Convert.ToSingle(objectResolvedBySimbad.RaDecCoordinate.Declination),
                    arcminutesSize.ToString(CultureInfo.InvariantCulture));

                await receivedMessage.Channel.SendMessageAsync(new SendMessage(
                                                                   content : $"Image size: {Math.Round(arcminutesSize, 3)}' x {Math.Round(arcminutesSize, 3)}'",
                                                                   new List <Attachment>
                {
                    new SendAttachment
                    {
                        Name = $"{objectResolvedBySimbad.Name}.jpg",
                        Content = image
                    }
                })).ConfigureAwait(false);
            }

            return(true);
        }
        public async Task <bool> ExecuteRegexCommandAsync(ReceivedMessage receivedMessage, Match regexMatch)
        {
            var simbadClient = new SimbadClient();

            if (regexMatch.Groups["AstroObject"].Success)
            {
                await SearchForObjectByNameAsync(receivedMessage, regexMatch, simbadClient).ConfigureAwait(false);
            }
            if (regexMatch.Groups["CenterOfSearchRA"].Success ||
                regexMatch.Groups["CenterOfSearchName"].Success)
            {
                await SearchForObjectsAroundRaDecAsync(receivedMessage, regexMatch, simbadClient);
            }
            return(true);
        }
Beispiel #4
0
        public void TestBasicTapQuery()
        {
            var simbadClient = new SimbadClient();
            var testQuery    = @"
                -- Basic data from an object given one of its identifiers.
                SELECT basic.OID,
                    RA,
                    DEC,
                    main_id AS ""Name"",
                    coo_bibcode AS ""BiblioReference"",
                    nbref AS ""NbReferences"",
                    plx_value as ""Parallax"",
                    rvz_radvel as ""Radial velocity"",
                    galdim_majaxis,
                    galdim_minaxis,
                    galdim_angle AS ""Galaxy ellipse angle""
                FROM basic JOIN flux ON oidref = oid
                WHERE filter = 'B'
                    AND CONTAINS(POINT('ICRS', RA, DEC), CIRCLE('ICRS', 10, 5, 5)) = 1
                ORDER BY ""Name""; ";

            var result = simbadClient.QuerySimbad(new SimbadTAPQuery(testQuery));
        }
Beispiel #5
0
 public void TestFindObjectByName()
 {
     var objName      = "M31";
     var simbadClient = new SimbadClient();
     var foundObject  = simbadClient.FindObjectByName(objName);
 }
        private static async Task SearchForObjectsAroundRaDecAsync(ReceivedMessage receivedMessage, Match regexMatch, SimbadClient simbadClient)
        {
            RaDecCoordinate centerCoordinates = null;
            const float     radiusInDegrees   = 0.5f;

            try
            {
                if (regexMatch.Groups["CenterOfSearchRA"].Success)
                {
                    centerCoordinates = new RaDecCoordinate(
                        double.Parse(regexMatch.Groups["CenterOfSearchRA"].Value, CultureInfo.InvariantCulture),
                        double.Parse(regexMatch.Groups["CenterOfSearchDEC"].Value, CultureInfo.InvariantCulture));
                }
                else if (regexMatch.Groups["CenterOfSearchName"].Success)
                {
                    var name = regexMatch.Groups["CenterOfSearchName"].Value;
                    var queryAroundObject = simbadClient.FindObjectByName(name);
                    if (queryAroundObject == null)
                    {
                        await receivedMessage.Channel.SendMessageAsync($"No object with name {name} found in the SIMBAD databse!").ConfigureAwait(false);

                        return;
                    }

                    centerCoordinates = queryAroundObject.RaDecCoordinate;
                }
            }
            finally
            {
                if (centerCoordinates == null)
                {
                    await receivedMessage.Channel.SendMessageAsync("Could not parse RA/DEC coordinates").ConfigureAwait(false);
                }
            }

            var objectsAroundTarget = simbadClient.QueryAround(centerCoordinates, radiusInDegrees);
            var csvString           = CsvExporter.AstronomicalObjectsToCsv(objectsAroundTarget);
            await receivedMessage.Channel.SendMessageAsync($"Found {objectsAroundTarget.Count} objects around {centerCoordinates} within a radius of {radiusInDegrees}°:").ConfigureAwait(false);

            await receivedMessage.Channel.SendMessageAsync(
                new SendMessage(
                    content : null,
                    new List <Attachment>
            {
                new SendAttachment
                {
                    Name = "queryResult.csv",
                    Content = Encoding.ASCII.GetBytes(csvString)
                }
            })).ConfigureAwait(false);
        }
        private static async Task SearchForObjectByNameAsync(ReceivedMessage receivedMessage, Match regexMatch, SimbadClient simbadClient)
        {
            var objectName  = regexMatch.Groups["AstroObject"].Value;
            var foundObject = simbadClient.FindObjectByName(objectName);

            if (foundObject == null)
            {
                WriteObjectNotFound(receivedMessage, objectName);
                return;
            }

            await WriteObjectDetailsEmbeddedAsync(receivedMessage, foundObject).ConfigureAwait(false);
        }