carray-netcdf 1.0.13 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +79 -0
- data/CONTRIBUTING.md +75 -0
- data/LICENSE +21 -0
- data/README.md +108 -2
- data/bin/ncheader +223 -0
- data/bin/ncvar +160 -0
- data/carray-netcdf.gemspec +37 -19
- data/docs/00_introduction.md +72 -0
- data/docs/01_getting_started.md +114 -0
- data/docs/02_reading.md +216 -0
- data/docs/03_writing.md +418 -0
- data/docs/04_codec.md +373 -0
- data/docs/05_groups.md +200 -0
- data/docs/06_layer1.md +160 -0
- data/docs/07_cookbook.md +345 -0
- data/docs/08_cheatsheet.md +326 -0
- data/docs/09_cli.md +79 -0
- data/lib/carray/netcdf/codec.rb +536 -0
- data/lib/carray/netcdf/dim.rb +67 -0
- data/lib/carray/netcdf/file.rb +354 -0
- data/lib/carray/netcdf/group.rb +517 -0
- data/lib/carray/netcdf/var.rb +539 -0
- data/lib/carray/netcdf/version.rb +5 -0
- data/lib/carray/netcdf.rb +287 -0
- data/lib/carray-netcdf.rb +3 -1
- metadata +80 -25
- data/API.md +0 -270
- data/Rakefile +0 -12
- data/bin/ncdef2yaml +0 -60
- data/examples/test.nc +0 -0
- data/examples/test.rb +0 -41
- data/examples/time.rb +0 -11
- data/ext/extconf.rb +0 -11
- data/ext/rb_netcdflib.c +0 -2674
- data/lib/io/netcdf.rb +0 -848
data/Rakefile
DELETED
data/bin/ncdef2yaml
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require "carray-netcdf"
|
|
4
|
-
require "yaml"
|
|
5
|
-
|
|
6
|
-
NC_DATA_TYPES = ["char","byte","short","int","float","double"]
|
|
7
|
-
|
|
8
|
-
module Psych
|
|
9
|
-
module Visitors
|
|
10
|
-
class YAMLTree < Psych::Visitors::Visitor
|
|
11
|
-
alias_method :emit_coder_orig, :emit_coder
|
|
12
|
-
def emit_coder c, o
|
|
13
|
-
case c.type
|
|
14
|
-
when :seq
|
|
15
|
-
@emitter.start_sequence nil, c.tag, c.tag.nil?, c.style
|
|
16
|
-
c.seq.each do |thing|
|
|
17
|
-
accept thing
|
|
18
|
-
end
|
|
19
|
-
@emitter.end_sequence
|
|
20
|
-
else
|
|
21
|
-
emit_coder_orig c, o
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
class Hash
|
|
29
|
-
def encode_with(coder)
|
|
30
|
-
if NC_DATA_TYPES.include?(self.first[0])
|
|
31
|
-
coder.style = Psych::Nodes::Mapping::FLOW
|
|
32
|
-
end
|
|
33
|
-
coder.tag = nil
|
|
34
|
-
coder.map = self
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
class Array
|
|
39
|
-
|
|
40
|
-
def encode_with (coder)
|
|
41
|
-
if self.all?{|v| Numeric===v or String===v}
|
|
42
|
-
coder.style = Psych::Nodes::Mapping::FLOW
|
|
43
|
-
end
|
|
44
|
-
coder.tag = nil
|
|
45
|
-
coder.seq = self
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
class String
|
|
51
|
-
|
|
52
|
-
def to_yaml
|
|
53
|
-
return self
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
nc = NCFile.open(ARGV[0])
|
|
59
|
-
|
|
60
|
-
puts nc.definition.to_yaml
|
data/examples/test.nc
DELETED
|
Binary file
|
data/examples/test.rb
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
require "carray"
|
|
2
|
-
require "time"
|
|
3
|
-
require "yaml"
|
|
4
|
-
require "carray-netcdf"
|
|
5
|
-
|
|
6
|
-
metadata = YAML.load %{
|
|
7
|
-
dimensions:
|
|
8
|
-
time: 1440
|
|
9
|
-
variables:
|
|
10
|
-
time:
|
|
11
|
-
type: float
|
|
12
|
-
dim: [time]
|
|
13
|
-
standard_name: time
|
|
14
|
-
long_name: time
|
|
15
|
-
units: minutes since 2018-01-01 00:00:00 +09:00
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
out = NCFileWriter.new("test.nc", compression: 1)
|
|
19
|
-
out.define metadata
|
|
20
|
-
|
|
21
|
-
out["time"] = CArray.float(1440).seq(1)
|
|
22
|
-
|
|
23
|
-
out.close
|
|
24
|
-
|
|
25
|
-
nc = NCFile.open("test.nc")
|
|
26
|
-
|
|
27
|
-
time = nc["time"].to_time
|
|
28
|
-
|
|
29
|
-
p time[0].to_s
|
|
30
|
-
|
|
31
|
-
y = CArray.float(1440).seq(0,4*Math::PI/1440).sin
|
|
32
|
-
|
|
33
|
-
#timezone = "UTC"
|
|
34
|
-
timezone = ""
|
|
35
|
-
|
|
36
|
-
CA.gnuplot {
|
|
37
|
-
plot [time(time,"UTC"), y],
|
|
38
|
-
xtime: true,
|
|
39
|
-
x: ["Time (UTC)", nil, "%H:%M"]
|
|
40
|
-
}
|
|
41
|
-
|
data/examples/time.rb
DELETED
data/ext/extconf.rb
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
require "mkmf"
|
|
2
|
-
require "carray/mkmf"
|
|
3
|
-
|
|
4
|
-
$CFLAGS += " -Wall"
|
|
5
|
-
|
|
6
|
-
dir_config("netcdf", possible_includes("netcdf","netcdf3","netcdf-3"), possible_libs)
|
|
7
|
-
|
|
8
|
-
if have_carray() and have_header("netcdf.h") and have_library("netcdf")
|
|
9
|
-
create_makefile("carray/netcdflib")
|
|
10
|
-
end
|
|
11
|
-
|