gemini-hlsw / lucuma-catalog   0.48.10

GitHub
Scala versions: 3.x
Scala.js versions: 1.x

lucuma-catalog

Scala JVM/JS library to read votable catalogs.

VOTable

VOTable is an xml format to deliver astronomical table based data.

It has a heritage based on FITS, having a preamble of metadata describing the table rows and the data in a table format

lucuma-catalog provides functions to read the xml and convert it to lucuma-core SiderealTarget.

Usage

lucuma-catalog is centered around a single function.

  def siderealTargets(catalog: CatalogName): Pipe[F, String, EitherNec[CatalogProblem, Target.Sidereal]]

The function is an fs2 Pipe that will take a Stream[F, String], attempt to first parse its xml content and then produce a stream of Target.Sidereals. This means we don't need to wait for the whole document to be parsed to start getting results.

Note that we fail at the level of targets, this would allow to keep getting results even if one particular target cannot be read for any reason

Though VOTable is a formal standard different catalogs can use different metadata and thus we need to tell the targets function what specific catalog we are using.

Example

import lucuma.catalog._

val file    = new File("votabl.xml")

Blocker[IO].use { blocker =>
  io.file
    .readAll[IO](Paths.get(file.toURI), blocker, 1024)
    .through(text.utf8Decode)
    .through(siderealTargets(CatalogName.Simbad))
    .compile
    .lastOrError
    .unsafeRunSync()
}

Examples for JVM and JS are provided Each example will query Simbad using sttp as http client and pretty print the result.

fs2-data-xml

To stream parse xml we are using fs2-data-xml and fs2-data-csv