fs2-data-xml


License

License

Categories

Categories

Data
GroupId

GroupId

edu.gemini
ArtifactId

ArtifactId

fs2-data-xml_2.13
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

fs2-data-xml
fs2-data-xml
Project URL

Project URL

https://github.com/gemini-hlsw/lucuma-catalog
Project Organization

Project Organization

Association of Universities for Research in Astronomy, Inc. (AURA)
Source Code Management

Source Code Management

https://github.com/gemini-hlsw/lucuma-catalog

Download fs2-data-xml_2.13

How to add to project

<!-- https://jarcasting.com/artifacts/edu.gemini/fs2-data-xml_2.13/ -->
<dependency>
    <groupId>edu.gemini</groupId>
    <artifactId>fs2-data-xml_2.13</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/edu.gemini/fs2-data-xml_2.13/
implementation 'edu.gemini:fs2-data-xml_2.13:0.1.0'
// https://jarcasting.com/artifacts/edu.gemini/fs2-data-xml_2.13/
implementation ("edu.gemini:fs2-data-xml_2.13:0.1.0")
'edu.gemini:fs2-data-xml_2.13:jar:0.1.0'
<dependency org="edu.gemini" name="fs2-data-xml_2.13" rev="0.1.0">
  <artifact name="fs2-data-xml_2.13" type="jar" />
</dependency>
@Grapes(
@Grab(group='edu.gemini', module='fs2-data-xml_2.13', version='0.1.0')
)
libraryDependencies += "edu.gemini" % "fs2-data-xml_2.13" % "0.1.0"
[edu.gemini/fs2-data-xml_2.13 "0.1.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.13.3
co.fs2 : fs2-core_2.13 jar 2.4.1

Project Modules

There are no modules declared in this project.

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 Targets.

Usage

lucuma-catalog is centered around a single function.

  def targets(catalog: CatalogName): Pipe[F, String, ValidatedNec[CatalogProblem, Target]]

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 Targets. 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(targets(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, however the project is not yet available for both JVM/JS.

This is temporarily solved internalizing the code for the specific module and cross compile it here.

This won't not needed once https://github.com/satabin/fs2-data/issues/58 is solved

edu.gemini

Gemini High-Level Software Group

Versions

Version
0.1.0