Skip to content

Instantly share code, notes, and snippets.

@zepinto
Created January 17, 2015 17:17
Show Gist options
  • Save zepinto/33c6069446f98018d46d to your computer and use it in GitHub Desktop.
Save zepinto/33c6069446f98018d46d to your computer and use it in GitHub Desktop.
Groovy script that extracts CTD data from LSF and prints out the result as CSV
import pt.lsts.imc.*
import pt.lsts.imc.lsf.*
import pt.lsts.util.WGS84Utilities
// Obtain an LSF index object
idx = new LsfIndex(new File("/path/to/Data.lsf"))
// Create a scanner
scanner = new IndexScanner(idx);
// print the header of the CSV
println "time, latitude, longitude, depth, conductivity, temperature"
// while there are valid values in the file...
while (true) {
// look for the next Conductivity message from CTD entity
c = scanner.next(Conductivity.class, "CTD");
// look for the next Temperature message from CTD entity
t = scanner.next(Temperature.class, "CTD");
// look for the next EstimatedState message (from any entity)
s = scanner.next(EstimatedState.class);
// if one of the messages is missing, stop
if (!c || !t || !s)
break
// calculate absolute location from state
pos = WGS84Utilities.toLatLonDepth(s)
// print sample
println "$s.timestampMillis, ${pos[0]}, ${pos[1]}, ${pos[2]}, $c.value, $t.value"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment