Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "granules (--collection=COL|--nativeid=ID|--shortname=NAME) [flags]", Aliases: []string{"g", "gr", "gran", "granule"}, Short: "Search for and download collection granules", Long: ` Search for and download collection granules NASA Earthdata Authentication Most, if not all, providers require authentication which is generally provided via a netrc file, something like so: machine urs.earthdata.nasa.gov login <username> password <plain text password> NOTE: It is very important that this file is only accessible via your user. On Linux and OSX this can be done via 'chmod 0600 ~/.netrc'. For more details: https://wiki.earthdata.nasa.gov/display/EL/How+To+Access+Data+With+cURL+And+Wget `, Example: ` Search for all products with a collection short name prefix: cmrfetch granules -s "CLDMSK_*" Search for multiple collection short names: cmrfetch granules -s CLDMSK_L2_VIIRS_SNPP -s CLDMSK_L2_VIIRS_NOAA20,CLDMSK_L2_MODIS_Aqua Search for granules by filename: cmrfetch granules -c C1964798938-LAADS -f CLDMSK_L2_VIIRS_NOAA20.A2023115.0142.001.2023115140055.nc `, RunE: func(cmd *cobra.Command, args []string) error { flags := cmd.Flags() if !flags.Changed("collection") && !flags.Changed("nativeid") && !flags.Changed("shortname") && !flags.Changed("filename") { return fmt.Errorf("at least one of --collection, --shortname, --nativeid, or --filename is required") } netrc, err := flags.GetBool("netrc") failOnError(err) verbose, err := flags.GetBool("verbose") failOnError(err) output, err := flags.GetString("output") failOnError(err) yes, err := flags.GetBool("yes") failOnError(err) destdir, err := flags.GetString("download") failOnError(err) concurrency, err := flags.GetInt("download-concurrency") failOnError(err) clobber, err := flags.GetBool("download-clobber") failOnError(err) fields, err := flags.GetStringSlice("fields") failOnError(err) for _, name := range fields { if !arrayContains(validFields, name) { return fmt.Errorf("%s is not a valid field name", name) } } if flags.Changed("filename") && !flags.Changed("collection") { return fmt.Errorf("--collection is required when using --filename") } params, err := newParams(flags) if err != nil { return err } var logger *log.Logger if verbose { logger = log.New(os.Stderr, "", log.LstdFlags) } api := internal.NewCMRSearchAPI(logger) if destdir != "" { err = doDownload(context.TODO(), api, params, destdir, netrc, clobber, yes, verbose, concurrency) } else { err = do(api, params, output, fields, yes) } if err != nil { log.Fatalf("failed! %s", err) } return nil }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.