Skip to content

Commit e1e6ff8

Browse files
proway2Michael S
andauthored
Switch to float64 (#28)
* Switched from float32 to float64 * Fixed the comment. Co-authored-by: Michael S <[email protected]>
1 parent 8ab5874 commit e1e6ff8

File tree

4 files changed

+43
-49
lines changed

4 files changed

+43
-49
lines changed

coeffs/read.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type epochData struct {
3333
coeffs *[]float64
3434
}
3535

36-
// NewCoeffsData - returns an initialized IGRF SHC data.
36+
// NewCoeffsData - returns an initialized IGRF SHC data structure.
3737
func NewCoeffsData() (*IGRFcoeffs, error) {
3838
igrf := IGRFcoeffs{data: &map[string]*epochData{}}
3939
if err := igrf.readCoeffs(); err != nil {

igrf/igrf.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,20 @@ func IGRF(lat, lon, alt, date float64) (IGRFresults, error) {
9292
// }
9393

9494
res := IGRFresults{
95-
Declination: float32(d),
96-
DeclinationSV: float32(ddot),
97-
Inclination: float32(i),
98-
InclinationSV: float32(idot),
99-
HorizontalIntensity: float32(h),
100-
HorizontalSV: float32(hdot),
101-
NorthComponent: float32(x),
102-
NorthSV: float32(xdot),
103-
EastComponent: float32(y),
104-
EastSV: float32(ydot),
105-
VerticalComponent: float32(z),
106-
VerticalSV: float32(zdot),
107-
TotalIntensity: float32(f),
108-
TotalSV: float32(fdot),
95+
Declination: d,
96+
DeclinationSV: ddot,
97+
Inclination: i,
98+
InclinationSV: idot,
99+
HorizontalIntensity: h,
100+
HorizontalSV: hdot,
101+
NorthComponent: x,
102+
NorthSV: xdot,
103+
EastComponent: y,
104+
EastSV: ydot,
105+
VerticalComponent: z,
106+
VerticalSV: zdot,
107+
TotalIntensity: f,
108+
TotalSV: fdot,
109109
}
110110
return res, nil
111111
}

igrf/igrf_test.go

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -231,27 +231,21 @@ func toFloat64(str string) float64 {
231231
return float64(val)
232232
}
233233

234-
func toFloat32(str string) float32 {
235-
val, err := strconv.ParseFloat(str, 32)
236-
check(err)
237-
return float32(val)
238-
}
239-
240234
func getIGRFresults(line []string) IGRFresults {
241235
return IGRFresults{
242-
Declination: toFloat32(line[1]),
243-
DeclinationSV: toFloat32(line[2]),
244-
Inclination: toFloat32(line[3]),
245-
InclinationSV: toFloat32(line[4]),
246-
HorizontalIntensity: toFloat32(line[5]),
247-
HorizontalSV: toFloat32(line[6]),
248-
NorthComponent: toFloat32(line[7]),
249-
NorthSV: toFloat32(line[8]),
250-
EastComponent: toFloat32(line[9]),
251-
EastSV: toFloat32(line[10]),
252-
VerticalComponent: toFloat32(line[11]),
253-
VerticalSV: toFloat32(line[12]),
254-
TotalIntensity: toFloat32(line[13]),
255-
TotalSV: toFloat32(line[14]),
236+
Declination: toFloat64(line[1]),
237+
DeclinationSV: toFloat64(line[2]),
238+
Inclination: toFloat64(line[3]),
239+
InclinationSV: toFloat64(line[4]),
240+
HorizontalIntensity: toFloat64(line[5]),
241+
HorizontalSV: toFloat64(line[6]),
242+
NorthComponent: toFloat64(line[7]),
243+
NorthSV: toFloat64(line[8]),
244+
EastComponent: toFloat64(line[9]),
245+
EastSV: toFloat64(line[10]),
246+
VerticalComponent: toFloat64(line[11]),
247+
VerticalSV: toFloat64(line[12]),
248+
TotalIntensity: toFloat64(line[13]),
249+
TotalSV: toFloat64(line[14]),
256250
}
257251
}

igrf/result.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ package igrf
1818
// TotalIntensity (F): 53814.3 nT
1919
// TotalSV (F): 71.8 nT/yr
2020
type IGRFresults struct {
21-
Declination float32
22-
DeclinationSV float32
23-
Inclination float32
24-
InclinationSV float32
25-
HorizontalIntensity float32
26-
HorizontalSV float32
27-
NorthComponent float32
28-
NorthSV float32
29-
EastComponent float32
30-
EastSV float32
31-
VerticalComponent float32
32-
VerticalSV float32
33-
TotalIntensity float32
34-
TotalSV float32
21+
Declination float64
22+
DeclinationSV float64
23+
Inclination float64
24+
InclinationSV float64
25+
HorizontalIntensity float64
26+
HorizontalSV float64
27+
NorthComponent float64
28+
NorthSV float64
29+
EastComponent float64
30+
EastSV float64
31+
VerticalComponent float64
32+
VerticalSV float64
33+
TotalIntensity float64
34+
TotalSV float64
3535
}

0 commit comments

Comments
 (0)