Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gitanjali Thakur
Fpar DATA
Commits
191cb46c
Commit
191cb46c
authored
May 13, 2020
by
gitanjali Thakur
Browse files
pymodis script added
parent
dfb74581
Pipeline
#31891
passed with stage
in 6 minutes and 6 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.renku/refs/datasets/how_spr
0 → 120000
View file @
191cb46c
../../../pymodis/.renku/datasets/ad3d2f9a-2a89-4ac6-8286-86104be9e0c0/metadata.yml
\ No newline at end of file
pymodis/.renku/datasets/ad3d2f9a-2a89-4ac6-8286-86104be9e0c0/metadata.yml
0 → 100644
View file @
191cb46c
'
@context'
:
'
@version'
:
1.1
_id
:
'
@id'
_project
:
'
@context'
:
'
@version'
:
1.1
_id
:
'
@id'
created
:
schema:dateCreated
creator
:
'
@context'
:
'
@version'
:
1.1
_id
:
'
@id'
affiliation
:
schema:affiliation
alternate_name
:
schema:alternateName
email
:
schema:email
label
:
rdfs:label
name
:
schema:name
prov
:
http://www.w3.org/ns/prov#
rdfs
:
http://www.w3.org/2000/01/rdf-schema#
schema
:
http://schema.org/
'
@id'
:
schema:creator
name
:
schema:name
prov
:
http://www.w3.org/ns/prov#
schema
:
http://schema.org/
updated
:
schema:dateUpdated
version
:
schema:schemaVersion
'
@id'
:
schema:isPartOf
created
:
schema:dateCreated
creator
:
'
@context'
:
'
@version'
:
1.1
_id
:
'
@id'
affiliation
:
schema:affiliation
alternate_name
:
schema:alternateName
email
:
schema:email
label
:
rdfs:label
name
:
schema:name
prov
:
http://www.w3.org/ns/prov#
rdfs
:
http://www.w3.org/2000/01/rdf-schema#
schema
:
http://schema.org/
'
@id'
:
schema:creator
date_published
:
schema:datePublished
description
:
schema:description
files
:
'
@context'
:
'
@version'
:
1.1
_id
:
'
@id'
_project
:
'
@context'
:
'
@version'
:
1.1
_id
:
'
@id'
created
:
schema:dateCreated
creator
:
'
@context'
:
'
@version'
:
1.1
_id
:
'
@id'
affiliation
:
schema:affiliation
alternate_name
:
schema:alternateName
email
:
schema:email
label
:
rdfs:label
name
:
schema:name
prov
:
http://www.w3.org/ns/prov#
rdfs
:
http://www.w3.org/2000/01/rdf-schema#
schema
:
http://schema.org/
'
@id'
:
schema:creator
name
:
schema:name
prov
:
http://www.w3.org/ns/prov#
schema
:
http://schema.org/
updated
:
schema:dateUpdated
version
:
schema:schemaVersion
'
@id'
:
schema:isPartOf
added
:
schema:dateCreated
based_on
:
schema:isBasedOn
creator
:
'
@context'
:
'
@version'
:
1.1
_id
:
'
@id'
affiliation
:
schema:affiliation
alternate_name
:
schema:alternateName
email
:
schema:email
label
:
rdfs:label
name
:
schema:name
prov
:
http://www.w3.org/ns/prov#
rdfs
:
http://www.w3.org/2000/01/rdf-schema#
schema
:
http://schema.org/
'
@id'
:
schema:creator
name
:
schema:name
path
:
prov:atLocation
prov
:
http://www.w3.org/ns/prov#
schema
:
http://schema.org/
url
:
schema:url
wfprov
:
http://purl.org/wf4ever/wfprov#
'
@id'
:
schema:hasPart
identifier
:
schema:identifier
in_language
:
'
@context'
:
'
@version'
:
1.1
alternate_name
:
schema:alternateName
name
:
schema:name
schema
:
http://schema.org/
'
@id'
:
schema:inLanguage
keywords
:
schema:keywords
license
:
schema:license
name
:
schema:name
path
:
prov:atLocation
prov
:
http://www.w3.org/ns/prov#
same_as
:
'
@context'
:
'
@version'
:
1.1
_id
:
'
@id'
schema
:
http://schema.org/
url
:
schema:url
'
@id'
:
schema:sameAs
schema
:
http://schema.org/
short_name
:
schema:alternateName
tags
:
'
@context'
:
'
@version'
:
1.1
_id
:
'
@id'
commit
:
schema:location
created
:
schema:startDate
dataset
:
schema:about
description
:
schema:description
name
:
schema:name
schema
:
http://schema.org/
'
@id'
:
schema:subjectOf
url
:
schema:url
version
:
schema:version
wfprov
:
http://purl.org/wf4ever/wfprov#
'
@type'
:
-
prov:Entity
-
schema:Dataset
-
wfprov:Artifact
_id
:
https://renkulab.io/datasets/ad3d2f9a-2a89-4ac6-8286-86104be9e0c0
_label
:
ad3d2f9a-2a89-4ac6-8286-86104be9e0c0
_project
:
'
@type'
:
-
prov:Location
-
schema:Project
_id
:
https://renkulab.io/projects/gitanjali.thakur/fpar-data
created
:
'
2020-04-19T09:47:45.966000+00:00'
creator
:
'
@type'
:
-
prov:Person
-
schema:Person
_id
:
mailto:gitanjali.thakur@list.lu
affiliation
:
null
alternate_name
:
null
email
:
gitanjali.thakur@list.lu
label
:
gitanjali Thakur
name
:
gitanjali Thakur
name
:
Fpar DATA
updated
:
'
2020-04-19T09:47:45.966000+00:00'
version
:
'
3'
created
:
'
2020-05-13T12:03:35.887717+00:00'
creator
:
-
'
@type'
:
-
prov:Person
-
schema:Person
_id
:
mailto:gitanjali.thakur@list.lu
affiliation
:
null
alternate_name
:
null
email
:
gitanjali.thakur@list.lu
label
:
gitanjali Thakur
name
:
gitanjali Thakur
date_published
:
null
description
:
null
files
:
[]
identifier
:
ad3d2f9a-2a89-4ac6-8286-86104be9e0c0
in_language
:
null
keywords
:
[]
license
:
null
name
:
how_spr
path
:
.renku/datasets/ad3d2f9a-2a89-4ac6-8286-86104be9e0c0
same_as
:
null
short_name
:
how_spr
tags
:
[]
url
:
https://renkulab.io/datasets/ad3d2f9a-2a89-4ac6-8286-86104be9e0c0
version
:
null
pymodis/modis_download.py
0 → 100644
View file @
191cb46c
#!/usr/bin/env python
# script to download massive MODIS data from ftp
#
# (c) Copyright Luca Delucchi 2010
# Authors: Luca Delucchi
# Email: luca dot delucchi at iasma dot it
#
##################################################################
#
# This MODIS Python script is licensed under the terms of GNU GPL 2.
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
##################################################################
"""Script to download massive MODIS data"""
import
sys
import
os
import
getpass
try
:
from
pymodis
import
optparse_gui
WXPYTHON
=
True
except
:
WXPYTHON
=
False
from
pymodis
import
optparse_required
from
pymodis
import
downmodis
def
main
():
"""Main function"""
# usage
usage
=
"usage: %prog [options] destination_folder"
if
1
==
len
(
sys
.
argv
)
and
WXPYTHON
:
option_parser_class
=
optparse_gui
.
OptionParser
else
:
option_parser_class
=
optparse_required
.
OptionParser
parser
=
option_parser_class
(
usage
=
usage
,
description
=
'modis_download'
)
# url
parser
.
add_option
(
"-u"
,
"--url"
,
default
=
"https://e4ftl01.cr.usgs.gov"
,
help
=
"http/ftp server url [default=%default]"
,
dest
=
"url"
)
# username and password from stdin
parser
.
add_option
(
"-I"
,
"--input"
,
dest
=
"input"
,
action
=
"store_true"
,
help
=
"insert user and password from standard input"
)
# password
parser
.
add_option
(
"-P"
,
"--password"
,
dest
=
"password"
,
help
=
"password to connect to the server"
)
# username
parser
.
add_option
(
"-U"
,
"--username"
,
dest
=
"user"
,
help
=
"username to connect to the server"
)
# tiles
parser
.
add_option
(
"-t"
,
"--tiles"
,
dest
=
"tiles"
,
default
=
None
,
help
=
"string of tiles separated with comma "
"[default=%default for all tiles]"
)
# path to add the path in the server
parser
.
add_option
(
"-s"
,
"--source"
,
dest
=
"path"
,
default
=
"MOLT"
,
help
=
"directory on the http/ftp server "
"[default=%default]"
)
# path to add the url
parser
.
add_option
(
"-p"
,
"--product"
,
dest
=
"prod"
,
default
=
"MOD11A1.005"
,
help
=
"product name as on the http/ftp server "
"[default=%default]"
)
# delta
parser
.
add_option
(
"-D"
,
"--delta"
,
dest
=
"delta"
,
default
=
10
,
help
=
"delta of day from the first day "
"[default=%default]"
)
# first day
parser
.
add_option
(
"-f"
,
"--firstday"
,
dest
=
"today"
,
default
=
None
,
help
=
"the day to start download [default=%default is for"
" today]; if you want change data you must use "
"this format YYYY-MM-DD"
,
metavar
=
"FIRST_DAY"
)
# last day
parser
.
add_option
(
"-e"
,
"--endday"
,
dest
=
"enday"
,
default
=
None
,
metavar
=
"LAST_DAY"
,
help
=
"the day to stop download "
"[default=%default]; if you want change"
" data you must use this format YYYY-MM-DD"
)
# debug
parser
.
add_option
(
"-x"
,
action
=
"store_true"
,
dest
=
"debug"
,
default
=
False
,
help
=
"this is useful for debugging the "
"download [default=%default]"
)
# jpg
parser
.
add_option
(
"-j"
,
action
=
"store_true"
,
dest
=
"jpg"
,
default
=
False
,
help
=
"download also the jpeg files [default=%default]"
)
# only one day
parser
.
add_option
(
"-O"
,
dest
=
"oneday"
,
action
=
"store_true"
,
default
=
False
,
help
=
"download only one day, it set "
"delta=1 [default=%default]"
)
# all days
parser
.
add_option
(
"-A"
,
dest
=
"alldays"
,
action
=
"store_true"
,
default
=
False
,
help
=
"download all days, it useful for initial download"
" of a product. It overwrite the 'firstday' and "
"'endday' options [default=%default]"
)
# remove file with size = 0
parser
.
add_option
(
"-r"
,
dest
=
"empty"
,
action
=
"store_true"
,
default
=
False
,
help
=
"remove empty files (size equal to zero) from "
"'destination_folder' [default=%default]"
)
#parser.add_option("-A", dest="alldays", action="store_true", default=True,
#help="download all days from the first")
# set false several options
parser
.
set_defaults
(
oneday
=
False
)
parser
.
set_defaults
(
debug
=
False
)
parser
.
set_defaults
(
jpg
=
False
)
# return options and argument
(
options
,
args
)
=
parser
.
parse_args
()
# test if args[0] it is set
if
len
(
args
)
==
0
and
not
WXPYTHON
:
parser
.
print_help
()
sys
.
exit
(
1
)
if
len
(
args
)
==
0
:
parser
.
error
(
"You have to define the destination folder for HDF file"
)
if
not
os
.
path
.
isdir
(
args
[
0
]):
parser
.
error
(
"The destination folder is not a dir or not exists"
)
# check if oneday option it is set
if
options
.
oneday
:
options
.
delta
=
1
if
options
.
input
:
if
sys
.
version_info
.
major
==
3
:
user
=
input
(
"Username: "
)
else
:
user
=
raw_input
(
"Username: "
)
password
=
getpass
.
getpass
()
else
:
user
=
options
.
user
password
=
options
.
password
# set modis object
modisOgg
=
downmodis
.
downModis
(
url
=
options
.
url
,
user
=
user
,
password
=
password
,
destinationFolder
=
args
[
0
],
tiles
=
options
.
tiles
,
path
=
options
.
path
,
product
=
options
.
prod
,
today
=
options
.
today
,
enddate
=
options
.
enday
,
jpg
=
options
.
jpg
,
delta
=
int
(
options
.
delta
),
debug
=
options
.
debug
)
# connect to ftp
modisOgg
.
connect
()
if
modisOgg
.
nconnection
<=
20
:
# download data
modisOgg
.
downloadsAllDay
(
clean
=
options
.
empty
,
allDays
=
options
.
alldays
)
else
:
parser
.
error
(
"A problem with the connection occured"
)
#add options
if
__name__
==
"__main__"
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment