-
Notifications
You must be signed in to change notification settings - Fork 1
/
measurement_spdx.go
51 lines (40 loc) · 1.24 KB
/
measurement_spdx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package skreader
import "time"
// SPDX tm2714 documentation
// https://colour.readthedocs.io/en/v0.3.10/_modules/colour/io/ies_tm2714.html
// Online calculators
// https://www.ies.org/standards/standards-toolbox/tm-30-spectral-calculator/
// https://luox.app
type SPDXHeader struct {
Description string `xml:"Description"`
Comments string `xml:"Comments"`
Date string `xml:"Report_date"`
}
type SPDXSpectralDataPoint struct {
Wavelength float64 `xml:"wavelength,attr"`
Value float64 `xml:",chardata"`
}
type SPDXSpectralDistribution struct {
SpectralData []SPDXSpectralDataPoint `xml:"SpectralData"`
}
func NewSPDXHeader(measName, measNote string, measTime time.Time) SPDXHeader {
formattedTime := measTime.Format("2006-01-02T15:04:05")
header := SPDXHeader{
Description: measName,
Comments: measNote,
Date: formattedTime,
}
return header
}
func NewSPDXSpectralDistribution(meas *Measurement) SPDXSpectralDistribution {
spectralData := make([]SPDXSpectralDataPoint, len(meas.SpectralData1nm))
for i, val := range &meas.SpectralData1nm {
spectralData[i] = SPDXSpectralDataPoint{
Wavelength: float64(i) + 380,
Value: val.Val,
}
}
return SPDXSpectralDistribution{
SpectralData: spectralData,
}
}