diff --git a/.all-contributorsrc b/.all-contributorsrc index c9e690f0e..bfdbf3cc6 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -470,6 +470,41 @@ "contributions": [ "ideas" ] + }, + { + "login": "cclauss", + "name": "Christian Clauss", + "avatar_url": "https://avatars.githubusercontent.com/u/3709715?v=4", + "profile": "https://github.com/cclauss", + "contributions": [ + "maintenance", + "review", + "tool" + ] + }, + { + "login": "jrenrut", + "name": "Jeremy Turner", + "avatar_url": "https://avatars.githubusercontent.com/u/42989238?v=4", + "profile": "https://github.com/jrenrut", + "contributions": [ + "bug", + "code" + ] + }, + { + "login": "mfisher87", + "name": "Matt Fisher", + "avatar_url": "https://avatars.githubusercontent.com/u/3608264?v=4", + "profile": "https://mfisher87.github.io/", + "contributions": [ + "bug", + "code", + "doc", + "maintenance", + "test", + "infra" + ] } ], "contributorsPerLine": 7, diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 5d5c4530c..aeea99573 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -17,51 +17,56 @@ Thanks goes to these wonderful people (`emoji key Anna Valentine
Anna Valentine

💡 Anthony Arendt
Anthony Arendt

🐛 💼 📋 🔍 Bruce Wallin
Bruce Wallin

💻 📖 🤔 👀 💬 + Christian Clauss
Christian Clauss

🚧 👀 🔧 David Shean
David Shean

🐛 🧑‍🏫 Don Setiawan
Don Setiawan

🚇 📦 - Facundo Sapienza
Facundo Sapienza

💡 🐛 + Facundo Sapienza
Facundo Sapienza

💡 🐛 Fernando Perez
Fernando Perez

🎨 💼 🤔 JP Swinski
JP Swinski

💻 👀 + Jeremy Turner
Jeremy Turner

🐛 💻 Jessica
Jessica

🐛 💻 🖋 📖 🎨 💡 🤔 🚧 🧑‍🏫 📆 💬 👀 Joachim Meyer
Joachim Meyer

🧑‍🏫 🚧 Kelsey Bisson
Kelsey Bisson

🐛 💻 📖 🤔 💡 🤔 🧑‍🏫 💬 👀 - Lindsey Heagy
Lindsey Heagy

🧑‍🏫 👀 - Molly Wieringa
Molly Wieringa

🤔 + Lindsey Heagy
Lindsey Heagy

🧑‍🏫 👀 + Matt Fisher
Matt Fisher

🐛 💻 📖 🚧 ⚠️ 🚇 + Molly Wieringa
Molly Wieringa

🤔 Nicole Abib
Nicole Abib

💻 🤔 Rachel Wegener
Rachel Wegener

🐛 💻 📖 🤔 🚧 👀 ⚠️ Raphael Hagen
Raphael Hagen

📖 🎨 💻 🚇 👀 Romina Piunno
Romina Piunno

💻 🤔 🧑‍🏫 👀 + + Sarah Hall
Sarah Hall

🐛 💻 📖 🚧 ⚠️ Scott Henderson
Scott Henderson

🚧 Sebastian Alvis
Sebastian Alvis

📖 🚇 - - Shashank Bhushan
Shashank Bhushan

💡 Tian Li
Tian Li

🐛 💻 📖 💡 🤔 👀 ⚠️ 🔧 Tom Johnson
Tom Johnson

📖 🚇 Tyler Sutterley
Tyler Sutterley

📖 💻 🤔 💬 🛡️ ⚠️ + + Wei Ji
Wei Ji

🐛 💻 📖 💡 🤔 🚇 🚧 🧑‍🏫 💬 👀 ⚠️ 📢 Whyjay Zheng
Whyjay Zheng

🐛 💻 👀 Wilson Sauthoff
Wilson Sauthoff

👀 - - Zach Fair
Zach Fair

🐛 💻 📖 🤔 💬 👀 alexdibella
alexdibella

🐛 🤔 💻 bidhya
bidhya

💡 learn2phoenix
learn2phoenix

💻 + + liuzheng-arctic
liuzheng-arctic

📖 🐛 💻 🤔 👀 🔧 💡 nitin-ravinder
nitin-ravinder

🐛 👀 ravindraK08
ravindraK08

👀 - - rtilling
rtilling

🤔 smithb
smithb

🤔 tedmaksym
tedmaksym

🤔 trevorskaggs
trevorskaggs

🐛 💻 + + trey-stafford
trey-stafford

💻 🤔 🚧 👀 💬 diff --git a/README.rst b/README.rst index 5240a1113..5ef8b1ba7 100644 --- a/README.rst +++ b/README.rst @@ -85,6 +85,32 @@ Alternatively, you can also install icepyx using `pip - + classes_dev_uml - + icepyx.quest.dataset_scripts.argo.Argo @@ -87,316 +87,309 @@ icepyx.core.auth.EarthdataAuthMixin - -EarthdataAuthMixin - -_auth : NoneType -_s3_initial_ts : NoneType, datetime -_s3login_credentials : NoneType -_session : NoneType -auth -s3login_credentials -session - -__init__(auth) -__str__() -earthdata_login(uid, email, s3token): None + +EarthdataAuthMixin + +_auth : NoneType +_s3_initial_ts : NoneType, datetime +_s3login_credentials : NoneType +_session : NoneType +auth +s3login_credentials +session + +__init__(auth) +__str__() +earthdata_login(uid, email, s3token): None icepyx.core.query.GenQuery - -GenQuery - -_spatial -_temporal -dates -end_time -spatial -spatial_extent -start_time -temporal - -__init__(spatial_extent, date_range, start_time, end_time) -__str__() + +GenQuery + +_spatial +_temporal +dates +end_time +spatial +spatial_extent +start_time +temporal + +__init__(spatial_extent, date_range, start_time, end_time) +__str__() icepyx.core.granules.Granules - -Granules - -avail : list -orderIDs : list - -__init__() -download(verbose, path, restart) -get_avail(CMRparams, reqparams, cloud) -place_order(CMRparams, reqparams, subsetparams, verbose, subset, geom_filepath) + +Granules + +avail : list +orderIDs : list + +__init__() +download(verbose, path, restart) +get_avail(CMRparams, reqparams, cloud) +place_order(CMRparams, reqparams, subsetparams, verbose, subset, geom_filepath) icepyx.core.granules.Granules->icepyx.core.auth.EarthdataAuthMixin - - + + icepyx.core.query.Query - -Query - -CMRparams -_CMRparams -_about_product -_cust_options : dict -_cycles : list -_granules -_order_vars -_prod : NoneType, str -_readable_granule_name : list -_reqparams -_subsetparams : NoneType -_tracks : list -_version -cycles -dataset -granules -order_vars -product -product_version -reqparams -tracks - -__init__(product, spatial_extent, date_range, start_time, end_time, version, cycles, tracks, auth) -__str__() -avail_granules(ids, cycles, tracks, cloud) -download_granules(path, verbose, subset, restart) -latest_version() -order_granules(verbose, subset, email) -product_all_info() -product_summary_info() -show_custom_options(dictview) -subsetparams() -visualize_elevation() -visualize_spatial_extent() + +Query + +CMRparams +_CMRparams +_about_product +_cust_options : dict +_cycles : list +_granules +_order_vars +_prod : NoneType, str +_readable_granule_name : list +_reqparams +_subsetparams : NoneType +_tracks : list +_version +cycles +dataset +granules +order_vars +product +product_version +reqparams +tracks + +__init__(product, spatial_extent, date_range, start_time, end_time, version, cycles, tracks, auth) +__str__() +avail_granules(ids, cycles, tracks, cloud) +download_granules(path, verbose, subset, restart) +latest_version() +order_granules(verbose, subset, email) +product_all_info() +product_summary_info() +show_custom_options(dictview) +subsetparams() +visualize_elevation() +visualize_spatial_extent() icepyx.core.granules.Granules->icepyx.core.query.Query - - -_granules - - - -icepyx.core.granules.Granules->icepyx.core.query.Query - - -_granules + + +_granules icepyx.core.icesat2data.Icesat2Data - -Icesat2Data - - -__init__() + +Icesat2Data + + +__init__() icepyx.core.exceptions.NsidcQueryError - -NsidcQueryError - -errmsg -msgtxt : str - -__init__(errmsg, msgtxt) -__str__() + +NsidcQueryError + +errmsg +msgtxt : str + +__init__(errmsg, msgtxt) +__str__() icepyx.core.exceptions.QueryError - -QueryError - - - + +QueryError + + + icepyx.core.exceptions.NsidcQueryError->icepyx.core.exceptions.QueryError - - + + icepyx.core.APIformatting.Parameters - -Parameters - -_fmted_keys : NoneType, dict -_poss_keys : dict -_reqtype : NoneType, str -fmted_keys -partype -poss_keys - -__init__(partype, values, reqtype) -_check_valid_keys() -_get_possible_keys() -build_params() -check_req_values() -check_values() + +Parameters + +_fmted_keys : NoneType, dict +_poss_keys : dict +_reqtype : NoneType, str +fmted_keys +partype +poss_keys + +__init__(partype, values, reqtype) +_check_valid_keys() +_get_possible_keys() +build_params() +check_req_values() +check_values() icepyx.core.APIformatting.Parameters->icepyx.core.query.Query - - -_CMRparams + + +_CMRparams icepyx.core.APIformatting.Parameters->icepyx.core.query.Query - - -_reqparams + + +_reqparams icepyx.core.APIformatting.Parameters->icepyx.core.query.Query - - -_subsetparams + + +_subsetparams icepyx.core.APIformatting.Parameters->icepyx.core.query.Query - - -_subsetparams + + +_subsetparams icepyx.core.query.Query->icepyx.core.auth.EarthdataAuthMixin - - + + icepyx.core.query.Query->icepyx.core.query.GenQuery - - + + icepyx.quest.quest.Quest - -Quest - -datasets : dict - -__init__(spatial_extent, date_range, start_time, end_time, proj) -__str__() -add_argo(params, presRange): None -add_icesat2(product, start_time, end_time, version, cycles, tracks, files): None -download_all(path) -save_all(path) -search_all() + +Quest + +datasets : dict + +__init__(spatial_extent, date_range, start_time, end_time, proj) +__str__() +add_argo(params, presRange): None +add_icesat2(product, start_time, end_time, version, cycles, tracks, files): None +download_all(path) +save_all(path) +search_all() icepyx.quest.quest.Quest->icepyx.core.query.GenQuery - - + + icepyx.core.read.Read - -Read - -_filelist -_out_obj : Dataset -_product -_read_vars -filelist -is_s3 -product -vars - -__init__(data_source, glob_kwargs, out_obj_type, product, filename_pattern, catalog) -_add_vars_to_ds(is2ds, ds, grp_path, wanted_groups_tiered, wanted_dict) -_build_dataset_template(file) -_build_single_file_dataset(file, groups_list) -_combine_nested_vars(is2ds, ds, grp_path, wanted_dict) -_read_single_grp(file, grp_path) -load() + +Read + +_filelist +_out_obj : Dataset +_product +_read_vars +filelist +is_s3 +product +vars + +__init__(data_source, glob_kwargs, out_obj_type, product, filename_pattern, catalog) +_add_vars_to_ds(is2ds, ds, grp_path, wanted_groups_tiered, wanted_dict) +_build_dataset_template(file) +_build_single_file_dataset(file, groups_list) +_combine_nested_vars(is2ds, ds, grp_path, wanted_dict) +_read_single_grp(file, grp_path) +load() icepyx.core.read.Read->icepyx.core.auth.EarthdataAuthMixin - - + + icepyx.core.spatial.Spatial - -Spatial - -_ext_type : str -_gdf_spat : GeoDataFrame -_geom_file : NoneType -_spatial_ext -_xdateln -extent -extent_as_gdf -extent_file -extent_type - -__init__(spatial_extent) -__str__() -fmt_for_CMR() -fmt_for_EGI() + +Spatial + +_ext_type : str +_gdf_spat : GeoDataFrame +_geom_file : NoneType +_spatial_ext +_xdateln +extent +extent_as_gdf +extent_file +extent_type + +__init__(spatial_extent) +__str__() +fmt_for_CMR() +fmt_for_EGI() - + icepyx.core.spatial.Spatial->icepyx.core.query.GenQuery - - -_spatial + + +_spatial - + icepyx.core.spatial.Spatial->icepyx.core.query.GenQuery - - -_spatial + + +_spatial icepyx.core.temporal.Temporal - -Temporal - -_end : datetime -_start : datetime -end -start - -__init__(date_range, start_time, end_time) -__str__() + +Temporal + +_end : datetime +_start : datetime +end +start + +__init__(date_range, start_time, end_time) +__str__() - + icepyx.core.temporal.Temporal->icepyx.core.query.GenQuery - - -_temporal + + +_temporal @@ -427,57 +420,57 @@ icepyx.core.variables.Variables->icepyx.core.auth.EarthdataAuthMixin - - + + - + icepyx.core.variables.Variables->icepyx.core.query.Query - - -_order_vars + + +_order_vars - + icepyx.core.variables.Variables->icepyx.core.query.Query - - -_order_vars + + +_order_vars - + icepyx.core.variables.Variables->icepyx.core.read.Read - - -_read_vars + + +_read_vars - + icepyx.core.variables.Variables->icepyx.core.read.Read - - -_read_vars + + +_read_vars icepyx.core.visualization.Visualize - -Visualize - -bbox : list -cycles : NoneType -date_range : NoneType -product : NoneType, str -tracks : NoneType - -__init__(query_obj, product, spatial_extent, date_range, cycles, tracks) -generate_OA_parameters(): list -grid_bbox(binsize): list -make_request(base_url, payload) -parallel_request_OA(): da.array -query_icesat2_filelist(): tuple -request_OA_data(paras): da.array -viz_elevation(): (hv.DynamicMap, hv.Layout) + +Visualize + +bbox : list +cycles : NoneType +date_range : NoneType +product : NoneType, str +tracks : NoneType + +__init__(query_obj, product, spatial_extent, date_range, cycles, tracks) +generate_OA_parameters(): list +grid_bbox(binsize): list +make_request(base_url, payload) +parallel_request_OA(): da.array +query_icesat2_filelist(): tuple +request_OA_data(paras): da.array +viz_elevation(): (hv.DynamicMap, hv.Layout) diff --git a/doc/source/user_guide/documentation/classes_user_uml.svg b/doc/source/user_guide/documentation/classes_user_uml.svg index d5c17c066..8b1273598 100644 --- a/doc/source/user_guide/documentation/classes_user_uml.svg +++ b/doc/source/user_guide/documentation/classes_user_uml.svg @@ -4,11 +4,11 @@ - + classes_user_uml - + icepyx.core.auth.AuthenticationError @@ -30,313 +30,306 @@ icepyx.core.auth.EarthdataAuthMixin - -EarthdataAuthMixin - -auth -s3login_credentials -session - -earthdata_login(uid, email, s3token): None + +EarthdataAuthMixin + +auth +s3login_credentials +session + +earthdata_login(uid, email, s3token): None icepyx.core.query.GenQuery - -GenQuery - -dates -end_time -spatial -spatial_extent -start_time -temporal - - + +GenQuery + +dates +end_time +spatial +spatial_extent +start_time +temporal + + icepyx.core.granules.Granules - -Granules - -avail : list -orderIDs : list - -download(verbose, path, restart) -get_avail(CMRparams, reqparams, cloud) -place_order(CMRparams, reqparams, subsetparams, verbose, subset, geom_filepath) + +Granules + +avail : list +orderIDs : list + +download(verbose, path, restart) +get_avail(CMRparams, reqparams, cloud) +place_order(CMRparams, reqparams, subsetparams, verbose, subset, geom_filepath) icepyx.core.granules.Granules->icepyx.core.auth.EarthdataAuthMixin - - + + icepyx.core.query.Query - -Query - -CMRparams -cycles -dataset -granules -order_vars -product -product_version -reqparams -tracks - -avail_granules(ids, cycles, tracks, cloud) -download_granules(path, verbose, subset, restart) -latest_version() -order_granules(verbose, subset, email) -product_all_info() -product_summary_info() -show_custom_options(dictview) -subsetparams() -visualize_elevation() -visualize_spatial_extent() + +Query + +CMRparams +cycles +dataset +granules +order_vars +product +product_version +reqparams +tracks + +avail_granules(ids, cycles, tracks, cloud) +download_granules(path, verbose, subset, restart) +latest_version() +order_granules(verbose, subset, email) +product_all_info() +product_summary_info() +show_custom_options(dictview) +subsetparams() +visualize_elevation() +visualize_spatial_extent() icepyx.core.granules.Granules->icepyx.core.query.Query - - -_granules - - - -icepyx.core.granules.Granules->icepyx.core.query.Query - - -_granules + + +_granules icepyx.core.icesat2data.Icesat2Data - -Icesat2Data - - - + +Icesat2Data + + + icepyx.core.exceptions.NsidcQueryError - -NsidcQueryError - -errmsg -msgtxt : str - - + +NsidcQueryError + +errmsg +msgtxt : str + + icepyx.core.exceptions.QueryError - -QueryError - - - + +QueryError + + + icepyx.core.exceptions.NsidcQueryError->icepyx.core.exceptions.QueryError - - + + icepyx.core.APIformatting.Parameters - -Parameters - -fmted_keys -partype -poss_keys - -build_params() -check_req_values() -check_values() + +Parameters + +fmted_keys +partype +poss_keys + +build_params() +check_req_values() +check_values() icepyx.core.APIformatting.Parameters->icepyx.core.query.Query - - -_CMRparams + + +_CMRparams icepyx.core.APIformatting.Parameters->icepyx.core.query.Query - - -_reqparams + + +_reqparams icepyx.core.APIformatting.Parameters->icepyx.core.query.Query - - -_subsetparams + + +_subsetparams icepyx.core.APIformatting.Parameters->icepyx.core.query.Query - - -_subsetparams + + +_subsetparams icepyx.core.query.Query->icepyx.core.auth.EarthdataAuthMixin - - + + icepyx.core.query.Query->icepyx.core.query.GenQuery - - + + icepyx.core.read.Read - -Read - -filelist -is_s3 -product -vars - -load() + +Read + +filelist +is_s3 +product +vars + +load() icepyx.core.read.Read->icepyx.core.auth.EarthdataAuthMixin - - + + icepyx.core.spatial.Spatial - -Spatial - -extent -extent_as_gdf -extent_file -extent_type - -fmt_for_CMR() -fmt_for_EGI() + +Spatial + +extent +extent_as_gdf +extent_file +extent_type + +fmt_for_CMR() +fmt_for_EGI() - + icepyx.core.spatial.Spatial->icepyx.core.query.GenQuery - - -_spatial + + +_spatial - + icepyx.core.spatial.Spatial->icepyx.core.query.GenQuery - - -_spatial + + +_spatial icepyx.core.temporal.Temporal - -Temporal - -end -start - - + +Temporal + +end +start + + - + icepyx.core.temporal.Temporal->icepyx.core.query.GenQuery - - -_temporal + + +_temporal icepyx.core.variables.Variables - -Variables - -path -product -version -wanted : NoneType, dict - -append(defaults, var_list, beam_list, keyword_list) -avail(options, internal) -parse_var_list(varlist, tiered, tiered_vars) -remove(all, var_list, beam_list, keyword_list) + +Variables + +path +product +version +wanted : NoneType, dict + +append(defaults, var_list, beam_list, keyword_list) +avail(options, internal) +parse_var_list(varlist, tiered, tiered_vars) +remove(all, var_list, beam_list, keyword_list) icepyx.core.variables.Variables->icepyx.core.auth.EarthdataAuthMixin - - + + - + icepyx.core.variables.Variables->icepyx.core.query.Query - - -_order_vars + + +_order_vars - + icepyx.core.variables.Variables->icepyx.core.query.Query - - -_order_vars + + +_order_vars - + icepyx.core.variables.Variables->icepyx.core.read.Read - - -_read_vars + + +_read_vars - + icepyx.core.variables.Variables->icepyx.core.read.Read - - -_read_vars + + +_read_vars icepyx.core.visualization.Visualize - -Visualize - -bbox : list -cycles : NoneType -date_range : NoneType -product : NoneType, str -tracks : NoneType - -generate_OA_parameters(): list -grid_bbox(binsize): list -make_request(base_url, payload) -parallel_request_OA(): da.array -query_icesat2_filelist(): tuple -request_OA_data(paras): da.array -viz_elevation(): (hv.DynamicMap, hv.Layout) + +Visualize + +bbox : list +cycles : NoneType +date_range : NoneType +product : NoneType, str +tracks : NoneType + +generate_OA_parameters(): list +grid_bbox(binsize): list +make_request(base_url, payload) +parallel_request_OA(): da.array +query_icesat2_filelist(): tuple +request_OA_data(paras): da.array +viz_elevation(): (hv.DynamicMap, hv.Layout) diff --git a/doc/sphinxext/announce.py b/doc/sphinxext/announce.py index 6ff0e4884..e053f4b62 100644 --- a/doc/sphinxext/announce.py +++ b/doc/sphinxext/announce.py @@ -77,10 +77,7 @@ def get_authors(revision_range): # e.g. v1.0.1|HEAD maybe_tag, head = cur_release.split("|") assert head == "HEAD" - if maybe_tag in this_repo.tags: - cur_release = maybe_tag - else: - cur_release = head + cur_release = maybe_tag if maybe_tag in this_repo.tags else head revision_range = f"{lst_release}..{cur_release}" # authors, in current release and previous to current release. @@ -125,7 +122,7 @@ def get_authors(revision_range): # pre.discard("Homu") # Append '+' to new authors. - authors = [s + " +" for s in cur - pre] + [s for s in cur & pre] + authors = [s + " +" for s in cur - pre] + list(cur & pre) authors.sort() return authors diff --git a/icepyx/core/APIformatting.py b/icepyx/core/APIformatting.py index d660a642c..90b7f3ac6 100644 --- a/icepyx/core/APIformatting.py +++ b/icepyx/core/APIformatting.py @@ -73,7 +73,7 @@ def _fmt_readable_granules(dset, **kwds): # list of readable granule names readable_granule_list = [] # if querying either by 91-day orbital cycle or RGT - if "cycles" in kwargs.keys() or "tracks" in kwargs.keys(): + if "cycles" in kwargs or "tracks" in kwargs: # default character wildcards for cycles and tracks kwargs.setdefault("cycles", ["??"]) kwargs.setdefault("tracks", ["????"]) @@ -110,7 +110,7 @@ def _fmt_var_subset_list(vdict): """ subcover = "" - for vn in vdict.keys(): + for vn in vdict: vpaths = vdict[vn] for vpath in vpaths: subcover += "/" + vpath + "," @@ -298,9 +298,9 @@ def _check_valid_keys(self): # if self._wanted == None: # raise ValueError("No desired parameter list was passed") - val_list = list(set(val for lis in self.poss_keys.values() for val in lis)) + val_list = list({val for lis in self.poss_keys.values() for val in lis}) - for key in self.fmted_keys.keys(): + for key in self.fmted_keys: assert key in val_list, ( "An invalid key (" + key + ") was passed. Please remove it using `del`" ) @@ -317,7 +317,7 @@ def check_req_values(self): ), "You cannot call this function for your parameter type" reqkeys = self.poss_keys[self._reqtype] - if all(keys in self.fmted_keys.keys() for keys in reqkeys): + if all(keys in self.fmted_keys for keys in reqkeys): assert all( self.fmted_keys.get(key, -9999) != -9999 for key in reqkeys ), "One of your formatted parameters is missing a value" @@ -337,7 +337,7 @@ def check_values(self): spatial_keys = self.poss_keys["spatial"] # not the most robust check, but better than nothing... - if any(keys in self._fmted_keys.keys() for keys in spatial_keys): + if any(keys in self._fmted_keys for keys in spatial_keys): assert any( self.fmted_keys.get(key, -9999) != -9999 for key in spatial_keys ), "One of your formatted parameters is missing a value" @@ -410,13 +410,13 @@ def build_params(self, **kwargs): opt_keys = self.poss_keys["optional"] for key in opt_keys: - if key == "Coverage" and key in kwargs.keys(): + if key == "Coverage" and key in kwargs: # DevGoal: make there be an option along the lines of Coverage=default, which will get the default variables for that product without the user having to input is2obj.build_wanted_wanted_var_list as their input value for using the Coverage kwarg self._fmted_keys.update( {key: _fmt_var_subset_list(kwargs[key])} ) elif (key == "temporal" or key == "time") and ( - "start" in kwargs.keys() and "end" in kwargs.keys() + "start" in kwargs and "end" in kwargs ): self._fmted_keys.update( _fmt_temporal(kwargs["start"], kwargs["end"], key) diff --git a/icepyx/core/auth.py b/icepyx/core/auth.py index 2b5e796dd..8e263e730 100644 --- a/icepyx/core/auth.py +++ b/icepyx/core/auth.py @@ -107,11 +107,9 @@ def set_s3_creds(): # Only generate s3login_credentials the first time credentials are accessed, or if an hour # has passed since the last login - if self._s3login_credentials is None: - set_s3_creds() - elif (datetime.datetime.now() - self._s3_initial_ts) >= datetime.timedelta( - hours=1 - ): + if self._s3login_credentials is None or ( + datetime.datetime.now() - self._s3_initial_ts + ) >= datetime.timedelta(hours=1): set_s3_creds() return self._s3login_credentials diff --git a/icepyx/core/granules.py b/icepyx/core/granules.py index 205149f56..2c51e208b 100644 --- a/icepyx/core/granules.py +++ b/icepyx/core/granules.py @@ -75,14 +75,13 @@ def gran_IDs(grans, ids=False, cycles=False, tracks=False, dates=False, cloud=Fa if cloud is True: try: for link in gran["links"]: - if link["href"].startswith("s3") and link["href"].endswith( - (".h5", "nc") - ): - gran_s3urls.append(link["href"]) + href = link["href"] + if href.startswith("s3") and href.endswith((".h5", "nc")): + gran_s3urls.append(href) except KeyError: pass - if any([param is True for param in [cycles, tracks, dates]]): + if any(param is True for param in [cycles, tracks, dates]): # PRD: ICESat-2 product # HEM: Sea Ice Hemisphere flag # YY,MM,DD,HH,MN,SS: Year, Month, Day, Hour, Minute, Second diff --git a/icepyx/core/query.py b/icepyx/core/query.py index c6f63d59a..ed241662b 100644 --- a/icepyx/core/query.py +++ b/icepyx/core/query.py @@ -126,7 +126,7 @@ def __init__( **kwargs, ): # validate & init spatial extent - if "xdateline" in kwargs.keys(): + if "xdateline" in kwargs: self._spatial = spat.Spatial(spatial_extent, xdateline=kwargs["xdateline"]) else: self._spatial = spat.Spatial(spatial_extent) @@ -637,7 +637,7 @@ def subsetparams(self, **kwargs): else: # If the user has supplied a subset list of variables, append the # icepyx required variables to the Coverage dict - if "Coverage" in kwargs.keys(): + if "Coverage" in kwargs: var_list = [ "orbit_info/sc_orient", "orbit_info/sc_orient_time", @@ -653,7 +653,7 @@ def subsetparams(self, **kwargs): ] # Add any variables from var_list to Coverage that are not already included for var in var_list: - if var not in kwargs["Coverage"].keys(): + if var not in kwargs["Coverage"]: kwargs["Coverage"][var.split("/")[-1]] = [var] if self._subsetparams is None: @@ -741,9 +741,7 @@ def granules(self): """ - if not hasattr(self, "_granules"): - self._granules = Granules() - elif self._granules is None: + if not hasattr(self, "_granules") or self._granules is None: self._granules = Granules() return self._granules @@ -869,8 +867,8 @@ def show_custom_options(self, dictview=False): ] try: - all(key in self._cust_options.keys() for key in keys) - except AttributeError or KeyError: + all(key in self._cust_options for key in keys) + except (AttributeError, KeyError): self._cust_options = is2ref._get_custom_options( self.session, self.product, self._version ) @@ -999,7 +997,7 @@ def order_granules(self, verbose=False, subset=True, email=False, **kwargs): if self._reqparams._reqtype == "search": self._reqparams._reqtype = "download" - if "email" in self._reqparams.fmted_keys.keys() or email is False: + if "email" in self._reqparams.fmted_keys or email is False: self._reqparams.build_params(**self._reqparams.fmted_keys) elif email is True: user_profile = self.auth.get_user_profile() @@ -1022,7 +1020,7 @@ def order_granules(self, verbose=False, subset=True, email=False, **kwargs): self.granules # Place multiple orders, one per granule, if readable_granule_name is used. - if "readable_granule_name[]" in self.CMRparams.keys(): + if "readable_granule_name[]" in self.CMRparams: gran_name_list = self.CMRparams["readable_granule_name[]"] tempCMRparams = self.CMRparams if len(gran_name_list) > 1: diff --git a/icepyx/core/read.py b/icepyx/core/read.py index 437b059b9..28da685d7 100644 --- a/icepyx/core/read.py +++ b/icepyx/core/read.py @@ -120,7 +120,7 @@ def _parse_source(data_source, glob_kwargs={}) -> list: # if data_source is a directory glob search the directory and assign to _filelist data_source = os.path.join(data_source, "*") filelist = glob.glob(data_source, **glob_kwargs) - elif isinstance(data_source, str) or isinstance(data_source, Path): + elif isinstance(data_source, (Path, str)): if data_source.startswith("s3"): # if the string is an s3 path put it in the _filelist without globbing filelist = [data_source] @@ -661,11 +661,11 @@ def _build_dataset_template(self, file): """ is2ds = xr.Dataset( - coords=dict( - gran_idx=[np.uint64(999999)], - source_file=(["gran_idx"], [file]), - ), - attrs=dict(data_product=self.product), + coords={ + "gran_idx": [np.uint64(999999)], + "source_file": (["gran_idx"], [file]), + }, + attrs={"data_product": self.product}, ) return is2ds @@ -740,7 +740,7 @@ def _build_single_file_dataset(self, file, groups_list): "ATL23", ]: wanted_grouponly_set = set(wanted_groups_tiered[0]) - wanted_groups_list = list(sorted(wanted_grouponly_set)) + wanted_groups_list = sorted(wanted_grouponly_set) if len(wanted_groups_list) == 1: is2ds = self._read_single_grp(file, grp_path=wanted_groups_list[0]) else: diff --git a/icepyx/core/spatial.py b/icepyx/core/spatial.py index d810726b3..650ca06be 100644 --- a/icepyx/core/spatial.py +++ b/icepyx/core/spatial.py @@ -496,7 +496,7 @@ def __init__(self, spatial_extent, **kwarg): self._spatial_ext = [float(i) for i in arrpoly] # check for cross dateline keyword submission - if "xdateline" in kwarg.keys(): + if "xdateline" in kwarg: self._xdateln = kwarg["xdateline"] assert self._xdateln in [ True, @@ -542,10 +542,7 @@ def extent_as_gdf(self): """ # TODO: test this - if hasattr(self, "_xdateln"): - xdateln = self._xdateln - else: - xdateln = None + xdateln = self._xdateln if hasattr(self, "_xdateln") else None if not hasattr(self, "_gdf_spat"): if self._geom_file is not None: diff --git a/icepyx/core/variables.py b/icepyx/core/variables.py index b14ee1ed5..bf4a38c66 100644 --- a/icepyx/core/variables.py +++ b/icepyx/core/variables.py @@ -84,10 +84,7 @@ def __init__( self._path = val.check_s3bucket(path) # Set up auth - if self._path.startswith("s3"): - auth = self.auth - else: - auth = None + auth = self.auth if self._path.startswith("s3") else None # Read the product and version from the file self._product = is2ref.extract_product(self._path, auth=auth) self._version = is2ref.extract_version(self._path, auth=auth) @@ -111,11 +108,7 @@ def __init__( @property def path(self): - if self._path: - path = self._path - else: - path = None - return path + return self._path if self._path else None @property def product(self): @@ -271,7 +264,7 @@ def parse_var_list(varlist, tiered=True, tiered_vars=False): for vn in varlist: vpath, vkey = os.path.split(vn) # print('path '+ vpath + ', key '+vkey) - if vkey not in vgrp.keys(): + if vkey not in vgrp: vgrp[vkey] = [vn] else: vgrp[vkey].append(vn) @@ -321,7 +314,7 @@ def _check_valid_lists( # check if the list of variables, if specified, are available in the product if var_list is not None: for var_id in var_list: - if var_id not in vgrp.keys(): + if var_id not in vgrp: err_msg_varid = "Invalid variable name: " + var_id + ". " err_msg_varid = err_msg_varid + "Please select from this list: " err_msg_varid = err_msg_varid + ", ".join(vgrp.keys()) @@ -514,9 +507,9 @@ def append(self, defaults=False, var_list=None, beam_list=None, keyword_list=Non ) # update the data object variables - for vkey in final_vars.keys(): + for vkey in final_vars: # add all matching keys and paths for new variables - if vkey not in self.wanted.keys(): + if vkey not in self.wanted: self.wanted[vkey] = final_vars[vkey] else: for vpath in final_vars[vkey]: diff --git a/icepyx/quest/dataset_scripts/__init__.py b/icepyx/quest/dataset_scripts/__init__.py index 7834127ff..498059021 100644 --- a/icepyx/quest/dataset_scripts/__init__.py +++ b/icepyx/quest/dataset_scripts/__init__.py @@ -1 +1 @@ -from .dataset import * +from .dataset import * # noqa: F403 diff --git a/icepyx/quest/dataset_scripts/argo.py b/icepyx/quest/dataset_scripts/argo.py index b7f374bd6..b170feec0 100644 --- a/icepyx/quest/dataset_scripts/argo.py +++ b/icepyx/quest/dataset_scripts/argo.py @@ -45,10 +45,7 @@ def __init__(self, aoi, toi, params=["temperature"], presRange=None): self._apikey = "92259861231b55d32a9c0e4e3a93f4834fc0b6fa" def __str__(self): - if self.presRange is None: - prange = "All" - else: - prange = str(self.presRange) + prange = "All" if self.presRange is None else str(self.presRange) if self.argodata is None: df = "No data yet" @@ -297,7 +294,7 @@ def search_data(self, params=None, presRange=None, printURL=False) -> str: selectionProfiles = resp.json() # Consider any status other than 2xx an error - if not resp.status_code // 100 == 2: + if resp.status_code // 100 != 2: # check for the existence of profiles from query if selectionProfiles == []: msg = ( @@ -362,7 +359,7 @@ def _download_profile( print(resp.url) # Consider any status other than 2xx an error - if not resp.status_code // 100 == 2: + if resp.status_code // 100 != 2: return "Error: Unexpected response {}".format(resp) profile = resp.json() return profile @@ -477,7 +474,7 @@ def download(self, params=None, presRange=None, keep_existing=True) -> pd.DataFr profile_data = self._download_profile(i) profile_df = self._parse_into_df(profile_data[0]) merged_df = pd.concat([merged_df, profile_df], sort=False) - except: + except Exception: print("\tError processing profile {0}. Skipping.".format(i)) # now that we have a df from this round of downloads, we can add it to any existing dataframe diff --git a/icepyx/quest/quest.py b/icepyx/quest/quest.py index 872f962f8..b61376625 100644 --- a/icepyx/quest/quest.py +++ b/icepyx/quest/quest.py @@ -72,7 +72,7 @@ def __str__(self): if not self.datasets: str += "None" else: - for i in self.datasets.keys(): + for i in self.datasets: str += "{0}, ".format(i) str = str[:-2] # remove last ', ' @@ -187,7 +187,7 @@ def search_all(self, **kwargs): except KeyError: v.search_data() - except: + except Exception: dataset_name = type(v).__name__ print("Error querying data from {0}".format(dataset_name)) @@ -226,7 +226,7 @@ def download_all(self, path="", **kwargs): except KeyError: msg = v.download() print(msg) - except: + except Exception: dataset_name = type(v).__name__ print("Error downloading data from {0}".format(dataset_name)) diff --git a/icepyx/tests/test_Earthdata.py b/icepyx/tests/test_Earthdata.py index cfa2eb2c5..06b0bc150 100644 --- a/icepyx/tests/test_Earthdata.py +++ b/icepyx/tests/test_Earthdata.py @@ -65,11 +65,8 @@ def earthdata_login(uid=None, pwd=None, email=None, s3token=False) -> bool: try: url = "urs.earthdata.nasa.gov" mock_uid, _, mock_pwd = netrc.netrc(netrc).authenticators(url) - except: + except Exception: mock_uid = os.environ.get("EARTHDATA_USERNAME") mock_pwd = os.environ.get("EARTHDATA_PASSWORD") - if (uid == mock_uid) & (pwd == mock_pwd): - return True - else: - return False + return bool((uid == mock_uid) & (pwd == mock_pwd)) diff --git a/icepyx/tests/test_auth.py b/icepyx/tests/test_auth.py index 50ae1e6ca..9b720a0f8 100644 --- a/icepyx/tests/test_auth.py +++ b/icepyx/tests/test_auth.py @@ -23,9 +23,7 @@ def test_get_session(auth_instance): # Test that .s3login_credentials creates a dict with the correct keys def test_get_s3login_credentials(auth_instance): assert isinstance(auth_instance.s3login_credentials, dict) - expected_keys = set( - ["accessKeyId", "secretAccessKey", "sessionToken", "expiration"] - ) + expected_keys = {"accessKeyId", "secretAccessKey", "sessionToken", "expiration"} assert set(auth_instance.s3login_credentials.keys()) == expected_keys diff --git a/icepyx/tests/test_behind_NSIDC_API_login.py b/icepyx/tests/test_behind_NSIDC_API_login.py index 47d0a10d2..bf77da074 100644 --- a/icepyx/tests/test_behind_NSIDC_API_login.py +++ b/icepyx/tests/test_behind_NSIDC_API_login.py @@ -37,8 +37,8 @@ def test_get_custom_options_output(session): obs = is2ref._get_custom_options(session, "ATL06", "006") with open("./icepyx/tests/ATL06v06_options.json") as exp_json: exp = json.load(exp_json) - assert all(keys in obs.keys() for keys in exp.keys()) - assert all(obs[key] == exp[key] for key in exp.keys()) + assert all(keys in obs for keys in exp) + assert all(obs[key] == exp[key] for key in exp) ########## query module ########## diff --git a/icepyx/tests/test_quest.py b/icepyx/tests/test_quest.py index e4964fd38..1b8259aaa 100644 --- a/icepyx/tests/test_quest.py +++ b/icepyx/tests/test_quest.py @@ -26,9 +26,9 @@ def test_add_is2(quest_instance): obs = quest_instance.datasets - assert type(obs) == dict - assert exp_key in obs.keys() - assert type(obs[exp_key]) == exp_type + assert type(obs) is dict + assert exp_key in obs + assert type(obs[exp_key]) is exp_type assert quest_instance.datasets[exp_key].product == prod @@ -40,9 +40,9 @@ def test_add_argo(quest_instance): obs = quest_instance.datasets - assert type(obs) == dict - assert exp_key in obs.keys() - assert type(obs[exp_key]) == exp_type + assert type(obs) is dict + assert exp_key in obs + assert type(obs[exp_key]) is exp_type assert set(quest_instance.datasets[exp_key].params) == set(params) @@ -54,7 +54,7 @@ def test_add_multiple_datasets(quest_instance): # print(quest_instance.datasets["icesat2"].product) exp_keys = ["argo", "icesat2"] - assert set(exp_keys) == set(quest_instance.datasets.keys()) + assert set(exp_keys) == set(quest_instance.datasets) ########## ALL DATASET METHODS TESTS ########## diff --git a/pyproject.toml b/pyproject.toml index f345fb9b9..66eb7b6f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,6 +62,8 @@ version_file_template = 'version = "{version}"' local_scheme = "node-and-date" fallback_version = "unknown" +[tool.codespell] +ignore-words-list = "aas,socio-economic,toi" [tool.ruff] # DevGoal: Lint and format all Jupyter Notebooks, remove below. @@ -71,13 +73,12 @@ extend-exclude = ["*.ipynb"] # docstring-code-format = true # docstring-code-line-length = "dynamic" -[tool.codespell] -ignore-words-list = "aas,socio-economic,toi" - [tool.ruff.lint] select = [ + "C4", # flake8-comprehensions "E", # pycodestyle "F", # pyflakes + "SIM", # flake8-simplify ] ignore = [ # Line too long @@ -87,13 +88,7 @@ ignore = [ # overlong comments. # See: https://github.com/psf/black/issues/1713#issuecomment-1357045092 "E501", - # TODO: remove ignores below this line - # comparison syntax in tests - "E721", - # bare except - "E722", - # unable to detect undefined names - "F403", + "SIM105", # suppressible-exception ] [tool.ruff.lint.per-file-ignores]