earthpy
earthpy copied to clipboard
Custom file name for file download
Added the argument file_name
that can be used with custom url downloads in earthpy.data.get_data()
. Allows users to change the name of the final file downloaded. Can't be used with key
downloads.
Codecov Report
Merging #891 (4ff96db) into main (b625aae) will decrease coverage by
0.90%
. The diff coverage is53.84%
.
@@ Coverage Diff @@
## main #891 +/- ##
==========================================
- Coverage 93.91% 93.01% -0.90%
==========================================
Files 26 26
Lines 1708 1746 +38
==========================================
+ Hits 1604 1624 +20
- Misses 104 122 +18
Flag | Coverage Δ | |
---|---|---|
unittests | 93.01% <53.84%> (-0.90%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
earthpy/io.py | 50.00% <30.00%> (-2.75%) |
:arrow_down: |
earthpy/tests/test_io.py | 72.09% <62.06%> (-2.04%) |
:arrow_down: |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
@eculler if you can check this out and see if it does what you expect it too that would be appreciated!
This looks good to me! I will try running it with one of our NCEI downloads, too.
@eculler let me know the results of that!
Ok @nkorinek , so this looks like the design is what I was looking for, but currently the http parameters remain in the filename (the base file name is what I specified.):
>>> import earthpy as et
>>> et.data.get_data(url="https://www.ncei.noaa.gov/access/monitoring/climate-at-a-glance/city/time-series/USW00013876/tmax/12/1/1895-2023.csv?base_prd=true&begbaseyear=1991&endbaseyear=2020", file_name='birmingham_max_temperature')
Downloading from https://www.ncei.noaa.gov/access/monitoring/climate-at-a-glance/city/time-series/USW00013876/tmax/12/1/1895-2023.csv?base_prd=true&begbaseyear=1991&endbaseyear=2020
'/Users/elsa/earth-analytics/data/earthpy-downloads/birmingham_max_temperature.csv?base_prd=true&begbaseyear=1991&endbaseyear=2020'
>>>