75 lines
1.7 KiB
Go
75 lines
1.7 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
"starwiz.cn/sjy01/preprocessing/extract"
|
|
)
|
|
|
|
var (
|
|
dataId string
|
|
batch bool
|
|
output string
|
|
)
|
|
|
|
var extractCmd = &cobra.Command{
|
|
Use: "extract",
|
|
Short: "Extract data from raw data files",
|
|
Long: `Extract data from raw data files`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
if batch {
|
|
ps := params()
|
|
for _, p := range ps {
|
|
e := extract.NewExtractor(p)
|
|
aos, _ := e.ExtractAosData()
|
|
dats, _ := e.ExtractOriginalImageData(aos)
|
|
for i, d := range dats {
|
|
e.SeprateAuxAndImgData(d, i)
|
|
}
|
|
}
|
|
} else {
|
|
p := &extract.Params{
|
|
InputData: fmt.Sprintf("demo/data/%s.dat", dataId),
|
|
OutputPath: fmt.Sprintf("%s/%s", output, dataId),
|
|
TempPath: fmt.Sprintf("demo/temp/%s", dataId),
|
|
DataId: dataId,
|
|
Satellite: "SJY01",
|
|
}
|
|
e := extract.NewExtractor(p)
|
|
aos, _ := e.ExtractAosData()
|
|
dats, _ := e.ExtractOriginalImageData(aos)
|
|
for i, d := range dats {
|
|
e.SeprateAuxAndImgData(d, i)
|
|
}
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(extractCmd)
|
|
|
|
extractCmd.Flags().StringVarP(&dataId, "data-id", "d", "051622", "051622")
|
|
extractCmd.Flags().BoolVarP(&batch, "batch", "b", false, "true | false")
|
|
extractCmd.Flags().StringVarP(&output, "out", "o", "demo/output", "demo/output")
|
|
}
|
|
|
|
func params() []*extract.Params {
|
|
var params []*extract.Params
|
|
datas := []string{"051622", "051712", "051721",
|
|
"051813", "051821", "051823",
|
|
"051921", "051922", "052022"}
|
|
for _, d := range datas {
|
|
params = append(params, &extract.Params{
|
|
InputData: fmt.Sprintf("demo/data/%s.dat", d),
|
|
OutputPath: fmt.Sprintf("%s/%s", output, d),
|
|
TempPath: fmt.Sprintf("demo/temp/%s", d),
|
|
DataId: d,
|
|
Satellite: "SJY01",
|
|
})
|
|
}
|
|
|
|
return params
|
|
}
|