Permalink
Browse files

Merge pull request #16 from jiwalker-usgs/master

I'm going to merge this in (no changes to working code).  The new test can be changed to look at any file from John or Randy to check whether they did it right.  The perl code is probably not that useful, but I'll leave it in for debugging purposes mostly.
  • Loading branch information...
2 parents 19b27ae + 45104dc commit c1ee42413fa44ed67f780f3a58d9f93a2d2ebb5c @jiwalker-usgs jiwalker-usgs committed Feb 24, 2014
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+my $infile = shift or die "Must supply input file\n";
+open(FILE, "<$infile");
+while (my $line = <FILE>) {
+ if ($line =~ m/^#/) {
+ $line =~ s/\r\n//;
+ print "$line\n";
+ } else {
+ if ($line =~ m/^(\w+\s+)+\w+/) {
+ # var header
+ $line =~ s/\r\n//;
+ print "$line\n";
+ } elsif ($line =~ m/^(\d+\w\s+)+\d+\w/) {
+ $line =~ s/\r\n//;
+ print "$line\n";
+ } elsif ($line =~ m/^(\d{4}-\d{2}-\d{2}:\d{2}:\d{2}:\d{2})\s+\d+(\s+[\d\.]+)+/) {
+ my @elements = split(/\s+/, $line);
+ my $len = @elements;
+ printf("%s\t", $elements[0]);
+ printf("%6d", $elements[1]);
+ for (my $i=2; $i<$len; $i++) {
+ printf("\t%1.6e", $elements[$i]);
+ }
+ print "\n";
+ }
+ }
+}
@@ -9,28 +9,9 @@
* @author tkunicki
*/
public class PRMSAnimationFileMetaDataTest {
-
- public PRMSAnimationFileMetaDataTest() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() {
- }
-
- @After
- public void tearDown() {
- }
@Test
- public void findAnimationFile() throws Exception {
+ public void testOldAnimationFile() throws Exception {
URL url = getClass().getClassLoader().getResource("pcm.a1fi.1980-2099.annual.animation.nhru");
File oldMetaData = new File(url.getPath() + ".xml");
if (oldMetaData.exists()) {
@@ -39,5 +20,16 @@ public void findAnimationFile() throws Exception {
PRMSAnimationFileMetaData result = PRMSAnimationFileMetaData.getMetaData(url);
System.out.println(result);
}
+
+ @Test
+ public void testNewAnimationFile() throws Exception {
+ URL url = getClass().getClassLoader().getResource("cccma_post-processed.nhru");
+ File oldMetaData = new File(url.getPath() + ".xml");
+ if (oldMetaData.exists()) {
+ oldMetaData.delete();
+ }
+ PRMSAnimationFileMetaData result = PRMSAnimationFileMetaData.getMetaData(url);
+ System.out.println(result);
+ }
}
Oops, something went wrong.

0 comments on commit c1ee424

Please sign in to comment.