diff --git a/.circleci/config.yml b/.circleci/config.yml index 4f68972a..28ce7500 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,7 +18,7 @@ jobs: # get names of changed files echo "${changed_files} ">> changed_files.txt # Remove unwanted files from commit and count files changed - python parse-commit.py + python scripts/parse-commit.py # Get latest commit message echo $(git log -1 --pretty=%B) > commit_msg_latest.txt @@ -29,6 +29,15 @@ jobs: else echo "No files were modified in the last commit." fi + - run: + name: Get removed, renamed, or moved files + working_directory: ~/eds-lessons-website + command: | + deleted_files=$(git diff-tree --no-commit-id --name-only --diff-filter=D -r HEAD 2>&1) + # get names of changed files + echo "${deleted_files} ">> deleted_files.txt + python scripts/parse-deleted.py + ls - run: name: Get & print current branch working_directory: ~/eds-lessons-website @@ -44,7 +53,7 @@ jobs: command: | branch=$(head -1 eds-lessons-website/current_branch.txt) # Only clone eds.org if there are files to commit - if [[ -f ~/eds-lessons-website/website_files.txt ]] + if [[ -f ~/eds-lessons-website/website_files.txt ]] || [ -f ~/eds-lessons-website/deleted_files.txt ] then if [ "$branch" != "master" ] then @@ -55,7 +64,7 @@ jobs: then # clone the remote branch git clone --depth 1 https://${EDS_LESSONS_GITHUB_TOKEN_EL}@github.com/earthlab/earthlab.github.io.git -b "$branch" - echo "Looks like the branch doesn't existing on the eds.org website, created branch for you." + echo "Looks like the branch doesn't exist on the eds.org website, created branch for you." else # if the branch doesn't exist, clone master and checkout the branch as a new branch git clone --depth 1 https://${EDS_LESSONS_GITHUB_TOKEN_EL}@github.com/earthlab/earthlab.github.io.git @@ -78,17 +87,61 @@ jobs: git checkout -b website-autobuild fi fi - # Copy files to the live website repo - cd ~/eds-lessons-website - python move-files.py + + # Only Copy files to the live website repo if there are files to move + # This might be nice as it's own step. + if [[ -f website_files.txt ]] + then + cd ~/eds-lessons-website + python scripts/move-files.py + fi else echo "There are no changes, not cloning the website repo." fi + pwd + - run: + name: Delete removed/renamed/moved images from .io website + working_directory: ~/eds-lessons-website + command: | + if [[ -f deleted_image_files.txt ]] + then + echo -e "Deleting the following images:" + cat deleted_image_files.txt | while read line + do + echo $line + image_to_delete=~/earthlab.github.io/$line + rm $image_to_delete + done + else + echo "There are no images to remove in this PR!" + fi + - run: + name: Delete removed/renamed/moved markdown files and associated image directories from .io website + working_directory: ~/eds-lessons-website + command: | + ls + if [[ -f deleted_md_files.txt ]] + then + echo -e "Deleting the following notebooks and their images:" + cat deleted_md_files.txt | while read line + do + echo $line + post_to_delete=~/earthlab.github.io/$line + rm $post_to_delete + echo "$post_to_delete" + # clear images dir associated with post + image_dir_to_delete=~/earthlab.github.io/images/${line%.*} + rm -rf $image_dir_to_delete + echo "$image_dir_to_delete" + done + else + echo "There are no lessons and associated lesson images to remove in this PR!" + fi - run: - name: Push files to new repo + name: Push changes in files and images to earthlab.github.io repo working_directory: ~/earthlab.github.io command: | - if [[ -f ~/eds-lessons-website/website_files.txt ]] + if [[ -f ~/eds-lessons-website/website_files.txt ]] || [ -f ~/eds-lessons-website/deleted_files.txt ] then # Be sure to see how many files there are and only commit if there are more than 0 git status diff --git a/_posts/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-01-about-the-floods.md b/_posts/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-01-about-the-floods.md deleted file mode 100644 index d0e07d44..00000000 --- a/_posts/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-01-about-the-floods.md +++ /dev/null @@ -1,113 +0,0 @@ ---- -layout: single -deprecated: true -title: 'An Overview of the 2013 Colorado Floods' -excerpt: "The 2013 flood event caused significant damage throughout the state of Colorado, USA. Learn about what caused the 2013 floods in Colorado and also some of the impacts." -authors: ['Leah Wasser', 'Lauren Herwehe'] -modified: 2020-02-05 -category: [courses] -class-lesson: ['about-2013-floods'] -permalink: /courses/earth-analytics-python/python-open-science-toolbox/an-overview-of-the-floods/ -nav-title: 'CO Flood Overview' -dateCreated: 2018-05-24 -module-title: 'An Overview of the 2013 Floods in Colorado, USA' -module-nav-title: 'Flood overview ' -module-description: 'In this module you will learn about the causes and effects of floods as seen during the 2013 Colorado floods. You will learn how streamflow, precipitation, drought, and remote sensing data are used to better understand flooding.' -module-type: 'class' -class-order: 3 -week: 1 -sidebar: - nav: -author_profile: false -comments: true -order: 1 -course: 'earth-analytics-python' -topics: - remote-sensing: ['multispectral-remote-sensing'] - earth-science: ['flood-erosion'] - time-series: ---- -{% include toc title="In This Lesson" icon="file-text" %} - - -
- -## Learning Objectives -At the end of this activity, you will be able to: - -* Describe the events that lead up to the 2013 Colorado Floods - -## What You Need - -This is a reading to provide background on the 2013 flood events. You do not need anything to go through it. - -
- - -## About The 2013 Colorado Flood - -In early September 2013, a slow moving cold front moved through Colorado intersecting with a warm, humid front. The clash between the cold and warm fronts yielded heavy rain and devastating flooding across the Front Range of Colorado. Boulder County, Colorado, located where the Rocky Mountains meet the high plains, was impacted by this flood event. - -
- - Map of Boulder, Colorado and the Front Range. -
You can see Boulder just northwest of Denver in this map of Colorado. The Front Range runs from Wyoming to Pueblo, Colorado. Source: Wikipedia. -
-
- - -## What Is a Flood? -A flood is when water inundates normally dry land. Scientists (ecologists) often refer to floods as disturbance events. A disturbance event is a temporary change in environmental conditions that causes a large change to an ecosystem. Fires, earthquakes, tsunamis, air pollution, and human development are all examples of disturbance events. While floods and other disturbance events can happen in the span of a few minutes or days, their ecological impacts can last for decades or even longer. Other scientists may refer to floods as extreme events or even hazards. - -
- - Vehicles destroyed by Colorado floods -
Vehicles lay submerged in a creek in Broomfield, Colorado. Source: The Denver Post. -
-
- - -## A History of Floods in Colorado - -
- - The St. Vrain River before and after the Colorado floods -
Aerial image of the St. Vrain River in Boulder County, Colorado before (right) and after (left) the 2013 Colorado floods. Notice how the flood caused the flow path of the river to entirely shift in less than five days. This change in river flow impacted plants, animals, and humans. Source: KRCC. -
-
- - -Boulder County, and Colorado in general, are susceptible to both flash floods and river floods. Flash floods, like the 2013 Colorado floods, are sudden and intense increases in streamflow, usually due to extreme weather. River floods occur more slowly and are more predictable. The 2013 floods are classified as a “100 year flood.” This means that a flood of their magnitude has a 1% chance of occurring each year. The first major flood reported in Boulder occurred in 1894 and was also a 100 year flood. Boulder’s first non-native settlers came in 1858, so many unreported floods likely occurred prior to that one. - -
- - The 100-year floodplain in Boulder -
The 100-year floodplain in Boulder. Source: Floodsafety.com. -
-
- - -Boulder County’s landscape makes it prone to flooding. The nearby mountains create steep slopes and canyons which act as chutes ejecting water into the downstream plains. These mountains also create atmospheric conditions that lend to frequent isolated storms. In addition, the Front Range of Colorado is susceptible to wildfires and drought. These disturbance events make soil less able to absorb water, which both increases the likelihood of and exacerbates flooding. - -## How Do You Measure Flood Events and Impacts? -You can measure causes and effects of floods with a variety of data types including precipitation data, drought indices, stream discharge data, lidar terrain data and other remotely sensed imagery that shows areas that have visually changed due to erosion, mudslides and other impacts. - - - -| Data Type | Potential Data Source | -|-------------------------------|--------------------------------------------------------------------| -| Atmospheric Conditions | National Oceanic and Atmospheric Association (NOAA) GOES Satellite Data | -| Drought | National Drought Mitigation Center Drought Monitor | -| Precipitation | National Weather Service COOP data | -| Stream Discharge | United States Geological Survey (USGS) Surface Water Data| -| Lidar Terrain Data | USGS Lidar Data | -| Other remotely sensed imagery | USGS Landsat Data, European Space Agency Sentinel-2 Data, United States Department of Agriculture (USDA) NAIP Data | -| | - - -In the following sections you will learn more about each of the drivers and impacts of the floods and the data used to quantify these drivers and impacts. You will then learn how to work with different types of data in Python to better understand flood events including: - -* Stream discharge data -* Precipitation data -* Lidar data - diff --git a/_posts/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-02-flood-drivers.md b/_posts/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-02-flood-drivers.md deleted file mode 100644 index 9287d772..00000000 --- a/_posts/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-02-flood-drivers.md +++ /dev/null @@ -1,138 +0,0 @@ ---- -layout: single -deprecated: true -title: 'How the Atmosphere Drives Floods: The 2013 Colorado Floods' -excerpt: "Changes in the atmosphere, including how quickly a storm moves can impact the severity of a flood. Learn more about how atmospheric conditions impact flood events." -authors: ['Leah Wasser', 'Lauren Herwehe'] -modified: 2020-02-05 -category: [courses] -class-lesson: ['about-2013-floods'] -permalink: /courses/earth-analytics-python/python-open-science-toolbox/how-atmospheric-conditions-and-drought-impact-floods/ -nav-title: 'Atmosphere & Drought' -dateCreated: 2018-05-24 -module-type: 'class' -week: 1 -sidebar: - nav: -author_profile: false -comments: true -order: 2 -course: 'earth-analytics-python' -topics: - remote-sensing: ['multispectral-remote-sensing'] - earth-science: ['flood-erosion'] - time-series: ---- -{% include toc title="In This Lesson" icon="file-text" %} - - - -
- -## Learning Objectives -At the end of this activity, you will be able to: - -* Describe how atmospheric conditions contribute to flood events. -* Describe one method that is used to study and track atmospheric conditions. - -## What You Need - -This is a reading to provide background on the 2013 flood events. You do not need anything to go through it. - -
- - -## Primary Driver: Atmospheric Conditions - a Driver of Flood Impacts - -### What Are Atmospheric Conditions? -Atmospheric conditions are what produces weather. The term refers to the physical conditions in the Earth’s atmosphere including temperature, wind, clouds, and precipitation. - -### How Are Atmospheric Conditions Measured? - -Atmospheric conditions can be measured with ground-based or satellite observations. Ground measurements can include air temperature and heat indices, barometric pressure, humidity, precipitation, wind speed and direction, and solar radiation. There are several satellites that track atmospheric conditions, the most popular being the NOAA operated Geostationary Operational Environmental Satellite System. - -
- - GOES satellite imagery of the rain that caused the 2013 Colorado floods. -
This animated loop shows water vapor systems over the western area of North America during the Colorado floods, on September 12th, 2013, as recorded by the GOES-15 and GOES-13 satellites. Source: Cooperative Institute for Meteorological Satellite Studies (CIMSS). -
-
- - -The GOES system consists of space and ground tools that work together to support weather forecasting, severe storm tracking, and meteorology research. GOES satellites are “geostationary” meaning that they always remain over one particular point on the Earth’s surface, allowing them to provide dependable information on weather conditions in that location. - -### Where Can You Get Atmospheric Data? - -One source of atmospheric data is GOES satellite data on this NOAA Geostationary Satellite Server. - -### Atmospheric Conditions and the Colorado Floods -The storm that caused the 2013 flooding in Boulder began when a slow moving cold front intersected with a warm, humid front leading to heavy rain. The storm was kept in a confined area over the Eastern Range of the Rocky Mountains in Colorado by water vapor systems. This confinement resulted in a large amount of rainfall being dumped over the region in a short period of time. Over the course of just five days Boulder County received more rainfall than it does in a typical year. - -## Primary Driver: Drought as a Driver of Flood Impacts - -### What is Drought? -Drought is a disturbance event that occurs when a given area experiences below average precipitation. It can also be caused and exacerbated by the way that humans choose to distribute water resources. - -### How Are Droughts Measured? - -There are many ways to measure or quantify drought. The Palmer Drought Severity Index is one commonly used drought index. The Palmer Drought Severity Index is a measure of soil moisture content. It is calculated from soil available water content, precipitation and temperature data. The values range from extreme drought (values <-4.0) through near normal (-.49 to .49) to extremely moist (>4.0). - - -{:.output} - Downloading from https://ndownloader.figshare.com/files/16371473 - Extracted output to /root/earth-analytics/data/colorado-flood/. - - - - -{:.output} -{:.display_data} - -
- -Plot of Palmer Drought Index for Colorado 2005-2016. -
Plot of Palmer Drought Index for Colorado 2005-2016.
- -
- - - - -## Where Can You Get Drought Data? - -You can obtain data on drought and read more about different ways to measure it on the National Drought Mitigation Center website. - -## Drought and the Colorado Floods - -The 2013 flood occurred right at the end of a severe drought in Colorado. - - -
- - MODIS satellite image of a dust storm caused by drought in Colorado -
This MODIS satellite image of the Colorado-Kansas border shows a massive dust storm during the 2013 drought in Colorado. The image was taken in January, several months prior to the Colorado floods, and shows how drought led to soil transport that exacerbated the impacts of the flooding. Source: NASA Earth Observatory. -
-
- - -In a drought period, the top soil layers and the moisture-absorbing organic matter (generally plant and animal residues at various stages of decomposition) within them dry out. - -
- - Dry, compacted soil during a drought -
Dry, compacted soil during a drought. Source: Wikipedia. -
-
- - -Dry organic matter is less able to absorb moisture. It also can be easily relocated by wind, leaving only the harder less permeable earth beneath it. Some soil types, like clay, can dry out so much that they become almost as impermeable as pavement and unable to absorb water. - -
- - Soil layers diagram -
In this diagram of soils layers you can see the the organic and top soil layers that are often dried out during drought periods. Source:Wikipedia. -
-
- - -All of this causes water to flow across the soil rather than being absorbed into the soil. Water flowing over the soil and earth is referred to as overland flow. Often times the floods that have significant impacts on an area have a lot of overland flow. diff --git a/_posts/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-03-flood-drivers-precipitation.md b/_posts/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-03-flood-drivers-precipitation.md deleted file mode 100644 index 711e8b91..00000000 --- a/_posts/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-03-flood-drivers-precipitation.md +++ /dev/null @@ -1,187 +0,0 @@ ---- -layout: single -deprecated: true -title: 'Rain: a Driver of the 2013 Colorado Floods' -excerpt: "The amount and/or duration of rainfall can impact how severe a flood is. Learn how rainfall is measured and used to understand flood impacts." -authors: ['Leah Wasser', 'Lauren Herwehe'] -modified: 2020-02-05 -category: [courses] -class-lesson: ['about-2013-floods'] -permalink: /courses/earth-analytics-python/python-open-science-toolbox/how-rain-impacts-floods/ -nav-title: 'Precipitation' -dateCreated: 2018-05-24 -module-type: 'class' -week: 1 -sidebar: - nav: -author_profile: false -comments: true -order: 3 -course: 'earth-analytics-python' -topics: - remote-sensing: ['multispectral-remote-sensing'] - earth-science: ['flood-erosion'] - time-series: ---- -{% include toc title="In This Lesson" icon="file-text" %} - - - -
- -## Learning Objectives -At the end of this activity, you will be able to: - -* Describe how rainfall or precipitation contributes to a flood event. -* Describe how rainfall is measured. - -## What You Need - -This is a reading to provide background on the 2013 flood events. You do not need anything to go through it. - -
- - -## What Is Precipitation? - -Precipitation refers to moisture from the condensation of atmospheric water vapor that falls to the ground. The term precipitation can refer to rain, snow and even hail. While rainfall is the most common driver of flood events, ice and snow melt can also cause or exacerbate them. - -
- - Big Thompson River during the Colorado floods -
The Big Thompson River rages in Larimer County, Colorado during the 2013 Colorado floods. Source:The Denver Post. -
-
- - - -## How Is Precipitation Measured? - -Rainfall is reported as the total amount of rain (millimeters, centimeters, or inches) over a given area per period of time. Various types of gauges can be used to measure precipitation. They are often as simple as a small plastic cylinder with vertical ticks that collects water. These precipitation gauges can be manually checked. In some cases there are automated systems in place that will record precipitation over time. - -
- - Rain gage -
Image of a standard rain gage. Source:Wikipedia. -
-
- - -## Where Can You Find Precipitation Data? - -Several US governmental organizations collect precipitation data. In this lesson, you will use data from the National Weather Service (NWS) Cooperative Observer Platform (COOP). This platform, which is operated by thousands of volunteer weather observers, consists of over 11,000 stations, about 5,000 of them measuring climate. These climate stations report 24 hour minimum and maximum temperature, liquid equivalent precipitation, snowfall, snow depth, and other weather metrics. - -
- - Map of US COOP sites -
Map of US COOP sites. Source:National Weather Service. -
-
- - -Another ‘citizen science’ source of precipitation data is CoCoRaHS. In contrast with COOP, this volunteer network measures only precipitation. - -## Precipitation and the Colorado Floods - -The average annual precipitation (which includes rain and snow) in Boulder, Colorado is 20 inches. This precipitation comes from winter snow, intense summer thunderstorms, and intermittent storms throughout the year. The precipitation that led to the 2013 floods was a late summer storm. Due to the atmospheric conditions, the storm produced significant precipitation in a short period of time. - -### How Much Rain Did Boulder Get During the Floods? - -The figure below shows the total precipitation each month from 1948 to 2013 for a National Weather Service COOP site located in Boulder, CO. - - -{:.input} -```python -precip = pd.read_csv('data/colorado-flood/precipitation/805333-precip-daily-1948-2013.csv', - parse_dates=['DATE'], na_values=['999.99']) -# resample -precip_d = precip.set_index('DATE') - -daily_sum_precip = precip_d.resample('D').sum().apply(np.round, decimals=1) -# remove days with no rain -daily_sum_precip = daily_sum_precip[(daily_sum_precip.HPCP != 0.00)] - -# note when plottinglots of bars, snap = False will turn off the pixel snapping or set the width to be wider. -fig, ax = plt.subplots(figsize=(16, 8)) -ax.plot(daily_sum_precip.index, - daily_sum_precip['HPCP'].values, - 'o', - color='purple') -ax.set_title("Precipitation for Boulder Colorado 1948-2016") -plt.show() -``` - -{:.output} -{:.display_data} - -
- -Scatter plot showing daily precipitation values for Boulder from 1948 to 2016. -
Scatter plot showing daily precipitation values for Boulder from 1948 to 2016.
- -
- - - - -ABOVE: Graph of total monthly precipitation from 1948 to 2013 for the National Weather Service’s COOP site Boulder 2 (Station ID:050843). - -Within this 65 years of data, you can see that there is a jump in the amount of precipitation that was measured in September 2013. If you “zoom in” on the time period of fall 2013 (see the plot below) you will see the precipitation that led to the floods came in the span of just a few days. - - - -{:.output} -{:.display_data} - -
- -Plot of total daily precipitation from August 15th to September 15th, 2013 for a National Weather Service COOP site located in Boulder, CO. -
Plot of total daily precipitation from August 15th to September 15th, 2013 for a National Weather Service COOP site located in Boulder, CO.
- -
- - - - -## Stream Discharge - -### What Is Stream Discharge? - -Stream discharge, or flow, is the volume of water that moves through a designated point over a fixed period of time. Measuring stream discharge helps scientists understand the amount and velocity of water that is moving through an area, which is of particular interest during floods. - -### How Is Stream Discharge Measured? - -Stream discharge is calculated by multiplying the area of a cross section of the stream by the velocity. - -
- - How to measure stream discharge -
Schematic of how to measure stream discharge. It is measured by multiplying the area of a cross-section of the stream by the velocity. Source:USGS. -
-
- - - -### Where Can You Find Stream Discharge Data? - -One of the most common sources of stream data is the USGS which maintains a network of sensors in rivers and streams across the country. In addition to stream discharge, these sensors monitor other variables that are important to stream morphology and health such as water level, velocity, and direction of flow. - -### Stream Discharge and the Colorado Floods - -During the flooding in Boulder, the combination of atmospheric conditions, precipitation and drought yielded rapid increases in stream flow, which served as a secondary driver of the floods. Stream discharge in Boulder Creek during the 2013 floods was 100 times greater than average, causing the creek to overflow its banks. The velocity of the water in the streams allowed it to pick up and move significant debris - -The daily average data for the stream gauge along Boulder Creek, five miles downstream of downtown Boulder, is graphed below. This graph, paired with the graph of precipitation in the above section, shows that heavy precipitation led to a stream surge. As a result of this extreme discharge rate, water poured into the flood zone. - - -{:.output} -{:.display_data} - -
- -Plot of Daily Average Stream Discharge (CFS) for Boulder Creek from August 15th to September 15th, 2013 for a National Weather Service COOP site located in Boulder, CO. -
Plot of Daily Average Stream Discharge (CFS) for Boulder Creek from August 15th to September 15th, 2013 for a National Weather Service COOP site located in Boulder, CO.
- -
- - - diff --git a/_posts/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-04-terrain-impacts.md b/_posts/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-04-terrain-impacts.md deleted file mode 100644 index 11591ca7..00000000 --- a/_posts/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-04-terrain-impacts.md +++ /dev/null @@ -1,148 +0,0 @@ ---- -layout: single -deprecated: true -title: 'Measure Changes in the Terrain Caused by a Flood Using Lidar Data' -excerpt: "A flood event often changes the terrain as water moves sediment and debris across the landscape. Learn how terrain changes are measured using lidar remote sensing data." -authors: ['Leah Wasser', 'Lauren Herwehe'] -modified: 2020-02-05 -category: [courses] -class-lesson: ['about-2013-floods'] -permalink: /courses/earth-analytics-python/python-open-science-toolbox/measure-changes-in-terrain-caused-by-floods/ -nav-title: 'Terrain Changes' -dateCreated: 2018-05-24 -module-type: 'class' -week: 1 -sidebar: - nav: -author_profile: false -comments: true -order: 4 -course: 'earth-analytics-python' -topics: - remote-sensing: ['multispectral-remote-sensing'] - earth-science: ['flood-erosion'] - time-series: ---- -{% include toc title="In This Lesson" icon="file-text" %} - -
- -## Learning Objectives - -At the end of this activity, you will be able to: - -* Describe how lidar data are used to measure changes in the landscape after a flood. - -## What You Need - -This is a reading to provide background on the 2013 flood events. You do not need anything to go through it. - -
- - -## Measuring Impacts of the 2013 Colorado Floods - -The Colorado floods had significant environmental, social and economic impacts. Now that you have a better understanding of the flood’s drivers and how to measure them---including atmosphere and drought as well as precipitation and stream discharge---you will learn how to use remote sensing to measure the impacts of flood events on the landscape. - - - -Aerial imagery video of Lee Hill, near Boulder, CO, before and after the 2013 flood event. Source: NEON Science. - - -Last week you used Google Earth before and after imagery to view differences in the landscape in Boulder prior to and following the flood. In that exercise, you were able to see areas where roads and buildings were lost, where mudslides occurred, and more. - -In the following weeks, you will use Light Detection and Ranging (lidar) data to understand changes in terrain that occur during a flood. LiDAR data can be used to measure changes in elevation over time. - -
- - An emotional couple looks on at a home destroyed by the floods near Jamestown, Colorado.. -
An emotional couple looks on at a home destroyed by the floods near Jamestown, Colorado. Source:The Denver Post. -
-
- - -### How Floods Impact the Landscape - -### What Is Lidar Data? - -Watch the video below to learn more about how lidar data works. - - - - -### How Do You Use Lidar to Measure Flood Impacts on Landscapes? - -Sedimentation and erosion are common landscape impacts from flooding. These processes occur when heavy rain leads to increased streamflow, which leads to stream surges, which creates energy that erodes sediment from one place and moves it to another. Lidar sensors on satellites and airplanes scan the landscape and create models of the elevation of the earth’s surface. - -Lidar data collected before and after a flood event can be used to quantify sedimentation and erosion due to the flood. Lidar can also be used to quantify the loss or movement of trees, buildings, and other objects that are on the earth’s surface. - -Lidar data are often converted into raster format because it is easier to work with. A Digital Elevation Model (DEM) is a common lidar derived raster product. DEMs can be Digital Terrain Models (DTM), which measure only the elevation of the ground (terrain), or Digital Surface Models (DSM) which measure the elevation of everything on the surface of the earth, including trees, buildings, or other structures. - -Below you will use lidar data to create DEMs to analyze landscape change due to the Colorado floods. - -## Where Can You Find Lidar Data? - -Several public organizations offer free lidar data including: - -* USGS Earth Explorer -* OpenTopography -* The National Map -* National Ecological Observatory Network (NEON) - -The data that you will use this week in the course was collected by NEON. - -## Using Elevation Models to Track Flood Impacts - -### Use Digital Terrain Models to Track Changes in Terrain - -Below, you can see a Digital Terrain Model (DTM) created for the lower Four-Mile Canyon Creek area in Boulder, Colorado using data collected before and after the 2013 floods. These maps show subtle differences in elevation, particularly along the stream bed. However, it is challenging to really compare these maps with the naked eye. - - - -{:.output} -{:.display_data} - -
- -Plots of DTMs for Four Mile Canyon Creek in Boulder County, Colorado before and after the 2013 floods. -
Plots of DTMs for Four Mile Canyon Creek in Boulder County, Colorado before and after the 2013 floods.
- -
- - - - -## Digital Elevation Model of Difference (DoD) - -While the above DEMs look almost identical visually, they can be used to create another model that is more useful for the purpose of studying flood impacts, a Digital Elevation Model of Difference (DoD). A DoD is created by subtracting one DTM from the other and shows the change that occurred in a given location over a certain period of time. - -The DoD created with the Four Mile Canyon Creek DTMs is below. Areas in purple have a lower elevation after the flood; in other words, they have experienced erosion. Areas in green have a higher elevation after the flood and have experienced sedimentation. - - - -{:.output} -{:.display_data} - -
- -Plot of Digital Elevation Model of Difference (DoD) for Four Mile Canyon Creek DTMs. -
Plot of Digital Elevation Model of Difference (DoD) for Four Mile Canyon Creek DTMs.
- -
- - - - -Below is a cross-section showing the data represented by a DoD. The orange areas are where the earth's surface is lower than before and the teal areas are where the earth's surface is higher than before. - -
- - A cross section of what is represented in a Digital Elevation Model of Difference (DoD). -
A cross section of what is represented in a Digital Elevation Model of Difference (DoD). Source: NEON. -
-
- - -## Using Data to Study Floods and other Extreme Events - -Now you should have a better understanding of how data on drought, atmospheric conditions, precipitation, streamflow, and elevation can help you understand floods. Quantifying drivers and impacts with these tools allows scientists, city planners, developers, and homeowners to make educated choices to prepare for and respond to disturbance events. In the next lessons you will learn how to use Python to work with lidar data to understand landscape change. diff --git a/_posts/courses/earth-analytics-python/01-science-toolbox/python-open-science-toolbox/2018-02-05-os-01-why-open-science.md b/_posts/courses/earth-analytics-python/01-science-toolbox/python-open-science-toolbox/2018-02-05-os-01-why-open-science.md deleted file mode 100644 index ecccf021..00000000 --- a/_posts/courses/earth-analytics-python/01-science-toolbox/python-open-science-toolbox/2018-02-05-os-01-why-open-science.md +++ /dev/null @@ -1,107 +0,0 @@ ---- -layout: single -deprecated: true -title: 'Jupyter Notebooks - An Important Part of the Open Science Toolbox' -excerpt: "Jupyter Notebooks are a tool you can use to combine code, documentation and outputs in the same file. Learn how how to use Jupyter Notebooks for reproducible open science work." -authors: ['Leah Wasser', 'Martha Morrissey'] -modified: 2020-02-05 -category: [courses] -class-lesson: ['open-science-python'] -permalink: /courses/earth-analytics-python/python-open-science-toolbox/jupyter-notebooks-for-open-science/ -nav-title: "Why Open Science" -dateCreated: 2018-02-08 -module-title: 'Open Science Python' -module-nav-title: 'Open Science Python' -module-description: 'This module reviews why open science and best practices in python.' -module-type: 'class' -class-order: 2 -course: "earth-analytics-python" -week: 1 -sidebar: - nav: -author_profile: false -comments: true -order: 1 -topics: - reproducible-science-and-programming: ['python', 'jupyter-notebook'] ---- - - -{% include toc title="In This Lesson" icon="file-text" %} - -In this lesson you will learn how the importance of open science and how to use Jupyter Notebooks for reproducible work. -
- -## Learning Objectives - -At the end of this activity, you will be able to: - - * List benefits of using Jupyter Notebooks to create reports. - * Explain how Jupyter Notebooks are a useful tool in Open Science approaches. - * Explain one way that Jupyter Notebooks can benefit your research. - -## What You Need - be sure that you have Python and the earth analytics python environment installed on your computer. You should also have an `earth-analytics` directory setup on your computer with a `/data` directory with it - -
- - -## Why Open Science -Open science is about making scientific methods, data and outcomes -available to everyone. It can be broken down into several parts Gezelter 2009): - -* Transparency in experimental methodology, observation, and collection of data. -* Public availability and reusability of scientific data. -* Public accessibility and transparency of scientific communication. -* Using web-based tools to facilitate scientific collaboration. - -In this tutorial, you are not going to focus on all aspects of open science as listed above. However, you will learn about Jupyter Notebooks as one tool that can be used to connect data, methods and outputs to make your work: - -1. More transparent and -2. More available and accessible to the public and your colleagues. - -Jupyter notebooks allow you to connect data, code (methods used to process the data) and outputs. Jupyter Notebooks can be saved and shared in different formats such as html or pdf. - - -### Open Science Slide Show - -Click through the slideshow below to learn more about open science. - -View Slideshow: Share, Publish & Archive Code & Data - - -## About Jupyter Notebooks - -The `.ipynb` file format allows you to combine descriptive text, code blocks and code output. You can run the code in python and you can export the .ipynb file to a nicely rendered, shareable format like `.pdf` or html. When render your file to `.html` or pdf the code is run and so your code outputs including plots, and other figures appear in the rendered document. You will use Jupyter Notebooks (`.ipynb` files) to document workflows and to share code for data processing, analysis and visualization. - - -### Why Combine Markdown and Code in Jupyter Notebooks - -Mixing markdown with code in Jupyter Notebooks provides many advantages: - -* **Human readable:** it's much easier to read a web page or a report containing text and figures.By adding markdown or text around your code, your project becomes more user friendly and easier to understand. -* **Simple syntax:** markdown is a simple language to learn and can be learned quickly. This makes the learning curve for well-documented Jupyter Notebooks smaller. -* **Helpful Reminder for Your Future Self:** When you code, consider your future self. If you leave your future self a well documented set of jupyter notebooks that both run your code and describe the steps, then all components of your work are clearly documented. You and your future self then don't have to remember what steps, assumptions, tests were used to complete the workflow. -* **Easy to Modify:** You can easily extend or refine analyses contained within a Jupyter notebook by modifying existing or adding new code blocks. -* **Flexible export formats:** Analysis results stored in Notebooks can be disseminated in various formats including HTML, PDF and slideshows. -* **Easy to share:** If all of your analysis is contained and described in a one or more notebooks, it makes it easy to share with a colleague. Your colleague can also easily replicate your workflow. - - **Data Tip:** -You can easily create fully reproducible jupyter notebooks that can be run online using my binder. -{: .notice--success } - -### Jupyter Notebooks Are Beneficial to Your Colleagues - -The link between data, code and results makes Jupyter Notebooks powerful. You can share your entire workflow with your colleagues and they can quickly see your process. You can also write reports using .ipynb files which contain code and data analysis results. To enrich the document, you can add text, just like you would in a word document that describes your workflow, discusses your results and presents your conclusions - along side your analysis results. - -### Jupyter Notebooks Are Beneficial to You & Your Future Self - -Jupyter notebooks (`.ipynb`) are efficient. If you need to make changes to your workflow, you can simply modify the code and run the report again. Your future self will appreciate it too. Jupyter Notebooks allows you to add documentation to remind yourself of your process. Further, all of the code that you used is in the notebook ready to be rerun or modified at any time. - - **Data Tip:** -Many of the Earth Lab lessons, including this one, were created using Jupyter Notebooks! -{: .notice--success } - - -### Convert Notebooks to Shareable html Files -You can save Jupyter Notebooks containing code and markdown as `.html` files. When you save a notebook as `.html`, it creates a nicely rendered web page with the code and outputs visible along with the markdown rendered as nicely formatted text. This means that you can share the file with a colleague and they can see your entire workflow - without having to rerun your analysis. You will learn how how to save to `.html` and other formats later in this course. diff --git a/_posts/courses/earth-analytics-python/01-science-toolbox/python-open-science-toolbox/2018-02-05-os-02-file-organization-101.md b/_posts/courses/earth-analytics-python/01-science-toolbox/python-open-science-toolbox/2018-02-05-os-02-file-organization-101.md deleted file mode 100644 index 6c096df0..00000000 --- a/_posts/courses/earth-analytics-python/01-science-toolbox/python-open-science-toolbox/2018-02-05-os-02-file-organization-101.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -layout: single -deprecated: true -title: 'Why Expressive File and Folder Names Matter: File Organization For Reproducible Science' -excerpt: 'Learn why self-explanatory file and directory names are important when setting up a science project on your computer. This lesson provides a broad overview of file organization principles.' -authors: ['Leah Wasser', 'Martha Morrissey'] -modified: 2020-02-05 -category: [courses] -class-lesson: ['open-science-python'] -permalink: /courses/earth-analytics-python/python-open-science-toolbox/best-practices-file-organization/ -nav-title: 'File Organization Tips' -week: 1 -sidebar: - nav: -author_profile: false -comments: true -order: 2 -course: "earth-analytics-python" -topics: - reproducible-science-and-programming: ['python'] ---- -{% include toc title="In This Lesson" icon="file-text" %} - -In this lesson you will learn about file organization to make your own future life easier (so you can find things) and also to make it easier to collaborate with other people. - -
- -## Learning Objectives - -At the end of this activity, you will be able to: - -* Be able to describe the key characteristics of a well structured project. -* Be able to summarize in 1-3 sentences why good project structure can make your work more efficient and make it easier to collaborate with colleagues. -* Be able to explain what a working directory is. - -## What You Need - -You need to have Python and the `earth-analytics-python` anaconda environment installed on your computer. You should also have an `earth-analytics` directory setup on your computer with a `/data` directory in it. - -
- -## Characteristics of a Well Structured Project / Working Directory - -Please note that in this lesson, you will use a project directory as a working directory. - -### Organization - Files & Directories - -When it comes to structuring the names of the files and folders that create your project, the more self explanatory, the better. A well structured project directory should: - -* Utilize a naming convention that is: - - * **Human readable:** use directory names that are easy to understand. - * **Machine readable:** avoid funky characters OR SPACES. - * **Support sorting:** If you have a list of input files, it's nice to be able to sort them to quickly see what's there and find What You Need. - * **Preserve raw data so it's not modified:** We'll worry about this later. - -* Have easy to read directory names that contains components of the project (e.g. code, data, outputs, figures, etc) - - -### Which Filenames Are Most Self-explanatory? - -Your goal when structuring a project directory is to use a naming convention that someone who is not familiar with your project can quickly understand. Case in point, have a look at the graphic below. Which list of file names are the most self explanatory? The ones on the LEFT? Or the ones of the RIGHT? Consider the structure of your project as we build the project or working directory for our earth analytics tutorials in the next lesson. - - -
- - File and directory names that clearly indicate the type of information stored within that file or directory are the most useful or expressive to your colleagues or your future self as they allow you to quickly understand the structure and contents of a project directory. Source: Jenny Bryan, Reproducible Science Curriculum. -
Compare the list of file names on the LEFT to those on the right - which ones are easier to quickly understand? File and directory names that clearly indicate the type of information stored within that file or directory are the most useful or expressive to your colleagues or your future self as they allow you to quickly understand the structure and contents of a project directory. Source: Jenny Bryan, Reproducible Science Curriculum. -
-
diff --git a/_posts/courses/earth-analytics-python/01-science-toolbox/python-open-science-toolbox/2018-02-05-os-03-intro-to-markdown.md b/_posts/courses/earth-analytics-python/01-science-toolbox/python-open-science-toolbox/2018-02-05-os-03-intro-to-markdown.md deleted file mode 100644 index af7144e2..00000000 --- a/_posts/courses/earth-analytics-python/01-science-toolbox/python-open-science-toolbox/2018-02-05-os-03-intro-to-markdown.md +++ /dev/null @@ -1,210 +0,0 @@ ---- -layout: single -deprecated: true -title: 'Introduction to Markdown' -excerpt: 'Markdown is a syntax that is used to format text in text files, Jupyter Notebooks and even R Markdown files. Learn how to format text using Markdown.' -authors: ['Leah Wasser', 'Martha Morrissey', 'Data Carpentry'] -modified: 2020-02-05 -category: [courses] -class-lesson: ['open-science-python'] -permalink: /courses/earth-analytics-python/python-open-science-toolbox/use-markdown-in-jupyter-notebooks/ -nav-title: 'Intro to Markdown' -week: 1 -sidebar: - nav: -author_profile: false -comments: true -order: 3 -course: "earth-analytics-python" -topics: - reproducible-science-and-programming: ['markdown'] ---- -{% include toc title="In This Lesson" icon="file-text" %} - -This tutorial walks you through how to format text using `Markdown` to document your workflows in `Jupyter Notebook` files. - -
- -## Learning Objectives - -At the end of this activity, you will be able to: - -* Explain the role `Markdown` syntax for documentation -* Create headings using `Markdown` in `Jupyter Notebook` -* Italicize and bold text using `Markdown` in `Jupyter Notebook` -* Render images using `Markdown` in `Jupyter Notebook` - -
- - -## Markdown - -`Markdown` is a human readable syntax for formatting text documents. `Markdown` can be used to produce nicely formatted documents including PDFs and web pages. When you format text using `Markdown` in a document, it is similar to using the format tools (e.g. bold, heading 1, heading 2) in a word processing tool like Microsoft Word or Google Docs. - -However, instead of using buttons to apply formatting, you use syntax such as `**this syntax bolds text in markdown**` or `# Here is a heading`. `Markdown` allows you to format text - such as making headings, bolding and italicizing words, creating bulleted lists, adding links, formatting mathematical symbols and making tables. - - - **Data Tip:** -Learn more about Markdown -{: .notice--success } - - -### Markdown Syntax in Jupyter Notebook files - -`Jupyter Notebook` allows you to combine code (e.g. `Python`) and `Markdown` in one document using cells. A `Jupyter Notebook` file can contain cells that render text written using the `Markdown` syntax as well as cells that contain and run `Python` code. - -
- - An example Markdown cell in Jupyter Notebook. -
An example Markdown cell in Jupyter Notebook. -
-
- -You can use `Markdown` in a `Jupyter Notebook` file for many different purposes. It could be used to: - -* Document your workflow: You can add text to the document that describes the steps that you incorporated into your processing workflow (e.g. how data is being processed and what results are produced). -* Describe your data: You can describe the data that you are using (e.g. source, pre-processing, metadata). -* Interpret code outputs: You may even add some text that interprets or discusses the outputs. - -If you render your `Jupyter Notebook` file to HTML or PDF, this `Markdown` will appear as text on the output document. - - **Data Tip:** -This web page that you are reading right now is generated from a markdown document. In this tutorial, we cover the basic syntax of markdown. -{: .notice--success } - -## Get to Know the Markdown Syntax - -Markdown is simple plain text, that is styled using special characters, including: - -#: a header element - -**: bold text - -*: italic text - -` `: code blocks - -Explore using some basic `Markdown` syntax. - -### Emphasize Code and Words in Markdown - -When you type text in a `Markdown` document with no additional syntax, the text will appear as paragraph text. You can add additional syntax to that text to format it in different ways. - -For example, if you want to highlight a function or some code within a plain text paragraph, you can use one backtick on each side of the text ( `code-goes-here` ), like this: `Here is some code`. - -This is the backtick, or grave; not an apostrophe (on most US keyboards, it is on the same key as the tilde (~)). - -To add emphasis to other text, you can use also use the following syntax to **bold** or *italicize* words. - -For example: - -``` -The use of the backtick (e.g. `text` ) will be reserved for denoting code. -To add emphasis to other text, use **bold** or *italics*. -``` - -Notice that this sentence uses both a code highlight (`text`), bolding (**text**) and italics (*text*). - -As rendered `Markdown`, it looks like this: - -*** - -The use of the highlight ( `text` ) will be reserve for denoting code when -used in text. To add emphasis to other text use **bold** or *italics*. - -*** - -### Horizontal Lines (Rules) - -You can also create a horizonal line or rule to highlight a block of `Markdown` syntax (similar to the highlighting a block of code using ` `): - - *** - - - *** - -### Section Headings - -You can create a heading using the pound (`#`) sign. For the headers to render properly, there must be a space between the `#` and the header text. - -Heading one is denoted using one `#` sign, heading two is denoted using two `##` signs, etc, as follows: - -`## Heading Two - -### Heading Three - -#### Heading Four -` - -Here is the rendered `Markdown`: - -## Heading Two - -### Heading Three - -#### Heading Four - - -### Images - - - -`![alt text here](path-to-image-here)` - -If you want to embed an image from a website, you can use the following syntax: - -`![Markdown Logo is here.](https://www.fullstackpython.com/img/logos/markdown.png)` - -It will look like this: - -![Markdown Logo is here.](https://www.fullstackpython.com/img/logos/markdown.png) - -For relative paths (images stored on your computer) to work in `Python`, you need to place the image in the right location on your computer - RELATIVE to your `.ipynb` file. This is where good file management becomes extremely important. - -For a simple example of using relative paths, create a directory named `images` in your `earth-analytics` directory. - -If your `Jupyter Notebook` file (`.ipynb`) is located in root of this directory, and all images that you want to include in your report are located in the `images` directory within `earth-analytics`, then the path that you -would use for each image is: - -`images/image-name.png` - - -
- - This image of a silly dog is rendered using a relative path to this webpage created using Jupyter Notebook. -
This image of a silly dog is rendered using a relative path to this webpage created using Jupyter Notebook.
-
- - -If all of your images are in the `images` directory, then you will be able to easily find them. This also follows good file management practices because all of the images that you use in your report are contained within your project directory. - -
- -## Additional Resources - -* GitHub Guide on Markdown -* Jupyter Notebook Markdown Resources -
diff --git a/_posts/courses/earth-analytics-python/01-science-toolbox/python-open-science-toolbox/2018-02-05-os-04-jupyter-notebook.md b/_posts/courses/earth-analytics-python/01-science-toolbox/python-open-science-toolbox/2018-02-05-os-04-jupyter-notebook.md deleted file mode 100644 index 8b19ce43..00000000 --- a/_posts/courses/earth-analytics-python/01-science-toolbox/python-open-science-toolbox/2018-02-05-os-04-jupyter-notebook.md +++ /dev/null @@ -1,242 +0,0 @@ ---- -layout: single -deprecated: true -title: 'Introduction to the Jupyter Notebook Interface' -excerpt: 'The Jupyter Notebook is an interactive coding environment that allows you to combine code, documentation and outputs. Learn how to use the Jupyter notebook interface.' -authors: ['Martha Morrissey', 'Leah Wasser'] -modified: 2020-02-05 -category: [courses] -class-lesson: ['open-science-python'] -permalink: /courses/earth-analytics-python/python-open-science-toolbox/use-jupyter-notebooks/ -nav-title: 'Jupyter Notebook Interface' -week: 1 -sidebar: - nav: -author_profile: false -comments: true -order: 4 -course: "earth-analytics-python" -topics: - reproducible-science-and-programming: ['jupyter-notebook'] ---- -{% include toc title="In This Lesson" icon="file-text" %} - -This tutorial walks you through the `Jupyter Notebook` interface. - -
- -## Learning Objectives - -At the end of this activity, you will be able to: - -* Open `Jupyter Notebook` from the terminal. -* Write and run `Python` code and `Markdown` in `Jupyter Notebook`. -* Be able to add and run `Markdown` text in a `Jupyter Notebook` file. - -## What You Need - -* You will need to have Git, Bash, and Anaconda setup on your computer to complete this lesson. Instructions for setting up these tools are here: Setup Git/Bash and Anaconda -* You will also need to have the `earth-analytics-python` environment set up. Instructions for setting up this environment are here: Set up earth analytics python environment -* You will need to have completed the Introduction to Bash Shell lesson. - - -
- -Information below is adapted from materials developed by Project Jupyter, Datacamp, and Dataquest. - -## About Jupyter Notebook - -`Jupyter Notebook` supports a reproducible workflow. It allows you to: - -* Write and run inline code interactively. -* Share your work with colleagues, so they can see both your code and the code outputs. -* Document all aspects of your workflow using a combination of well-written code and `Markdown` text. - - -## Advantages of Jupyter Notebook - -`Jupyter Notebook` also makes coding more efficient. - -* **Shortcuts**: `Jupyter Notebook` has different shortcuts for running cells, adding new cells and formatting the notebook to help save you time -* **Autocomplete** : Autocomplete is available to quickly find function names, arguments for those functions, and variables that are stored in your environment. This makes typing your code easier and less error-prone. Hitting tab while typing will prompt `Jupyter Notebook` to help you complete the name of a function or variable that you want to call. -* **Markdown Integration**: You can combine text and code in the same document. This allows you to document and explain the code you have written and make your workflow more reproducible. - - - -## Get to Know Jupyter Notebook - -In this lesson, you will explore Jupyter Notebook, the Integrated Development Environment (IDE) that you will use to write code, navigate files on our computer, inspect variables and more. - -An IDE is different from a text editor. IDEs allow you to write, test, and debug code. - -Other commonly used `Python` IDEs are Spyder (which comes with the `Python` Anaconda distribution) and PyCharm. There are many tools to help you code, but in this class, you will use `Jupyter Notebook`. - -`Jupyter Notebook` is an open source product and free under the BSD 3-clause "New" or "Revised" License. - - -### How to Start Jupyter Notebook - -* To launch `Jupyter Notebook` via the terminal, first make sure you are in the `earth-analytics` directory and that the `earth-analytics-python` environment has been activated. Then, you can launch `Jupyter Notebook` by typing `jupyter notebook`. - -``` bash -$ source activate earth-analytics-python -$ cd earth-analytics -$ jupyter notebook -``` - -If you are on Windows, use `activate earth-analytics-python` to active the conda environment: - -``` bash -$ activate earth-analytics-python -$ cd earth-analytics -$ jupyter notebook -``` - -### Jupyter Notebooks combine three components: - -1. **The Jupyter Notebook**: `Jupyter Notebook` is a web application that launches in a web browser like Firefox or Safari. The notebook is where you write and run your code. - -2. **Kernels**: A kernel is the program that runs your code. For instance, if you want to run `Python` code, then you will run a `Python` kernel in `Jupyter Notebook`. The kernel runs your code in the given language and returns output back to the `Jupyter Notebook` web application. `Jupyter Notebook` supports over 40 different kernel languages. In this class, you will use `Python`. Specifically, you will use the `earth-analytics-python` kernel which contains all of the libraries that you need for this course. - -3. **Notebook documents** The notebook document is the file that you use to store your code and `Markdown`. Each `Jupyter Notebook` file has an `.ipynb` extension. - - -
- - Sample Jupyter Notebook from Jupyter documentation indicating the location of the toolbar, menu bar, cell in command mode, and kernel indicator. -
Sample Jupyter Notebook from Jupyter documentation indicating the location of the toolbar, menu bar, cell in command mode, and kernel indicator. -
-
- - - -When you first start the Jupyter Notebook server, your browser will open to the notebook dashboard. - -
- - Jupyter notebook dashboard with one notebook called week1 and a data folder. -
Jupyter notebook dashboard with one notebook called week1 and a data folder. -
-
- -The dashboard serves as a homepage for `Jupyter Notebook`. Its main purpose is to display the notebooks and files in the current directory. For this class, you will always work in the `earth-analytics` directory. - - -#### Explore the Jupyter Notebook Interface - -When you open or create a new `Jupyter Notebook` file, you will see three main parts: -* Menu -* Toolbar -* Notebook Area and Cells - -### Work With Markdown and Code Cells in Jupyter Notebooks - -A `Jupyter Notebook` file consists of a set of cells that can store text or code. You will focus on code and `Markdown` cells for this lesson. - -* **Text Cells:** Text cells allow you to write `Markdown`. This is where you will describe your workflow. -* **Code Cells:** Allow you to write code (e.g. using `Python`). - -
- - You can change the type of any cell using the drop down. Cell type options include code, markdown, Raw NBConvert, and heading. -
You can change the type of any cell using the drop down. Cell type options include code, markdown, Raw NBConvert, and heading. There are also shortcuts to enter the command mode. To use shortcuts, hit the esc key. After that, you can change a cell to Markdown by hitting the “m” key, or you can change a cell to code by hitting the “y” key. -
-
- -For a full list of keyboard shortcuts, click the help button, then the keyboard shortcuts button. - -
- - Help menu of Jupyter Notebook. -
Help menu of Jupyter Notebook. -
-
- -### Markdown Cells in Jupyter - -A `Jupyter Notebook` file can contain text written using the `Markdown` syntax, in a cell that is specified for markdown. - -
- - Jupyter Notebook with a non-rendered Markdown cell. -
Jupyter Notebook with a non-rendered Markdown cell. -
-
- -
- - Jupyter Notebook with a rendered Markdown cell. -
Jupyter Notebook with a rendered Markdown cell. -
-
- - - -### Code Cells in Jupyter Notebooks - - -You can add code to the code cells in `Jupyter Notebook`. Code is written in code chunks. When you run the code in a cell, the code output displayed below. A cell can be run by hitting the run button or using a keyboard shortcut, as discussed in the next section. - -
- - Jupyter Notebook with a code cell that contains 4 + 5. When you run the code, the output is 9 and is displayed below the code cell. -
Jupyter Notebook with a code cell that contains 4 + 5. When you run the code, the output is 9 and is displayed below the code cell. -
-
- -For more information on code in `Jupyter Notebook`, see the next lesson on Install and Import Python Packages. - - - -### Useful Jupyter Shortcuts For Running Code and Adding Cells - -#### Menu Tools vs. Keyboard Shortcuts - -* You can manipulate your `Jupyter Notebook` using the drop down tools from the menu, with keyboard shortcuts, or using both. -* Keyboard shortcuts allow your workflow to be faster and more efficient. -* The most important keyboard shortcuts are Enter, which enters edit mode, and Esc, which enters command mode. - * **Enter Mode** is indicated by green around cells and is for editing the contents of a cell - * **Command Mode** is indicated by a grey cell border with blue on the left edge. This mode allows you to edit the notebook as a whole. - -The table below shows common tasks in `Jupyter Notebook` and how to do them using keyboard shortcuts or the menu tool. - - -Function | Keyboard Shortcut | Menu Tools ---- | --- | --- -Save notebook | Esc + s | File → Save and Checkpoint -Create new cell| Esc + a (above), Esc + b (below) | Insert→ cell above Insert → cell below -Run Cell | Ctrl + enter| Cell → Run Cell -Copy Cell | c | Copy Key -Paste Cell | v | Paste Key -Interrupt Kernel| Esc + i i | Kernel → Interrupt -Restart Kernel | Esc + 0 0 | Kernel → Restart -Find and replace on your code but not the outputs | Esc + f | N/A -merge multiple cells| Shift + M| N/A -When placed before a function Information about a function from its documentation| ? | N/A - - - - - **Data Tip:** -Inline magic are commands built into the Python kernel and always start with a %. Magic commands are useful shortcuts. Magic commands always start with a % because this symbol isn’t valid in Python. Magic commands also only work on the ipython kernel. Magic commands provide shortcuts to common tasks that would normally take several lines of code to accomplish in Python. -{: .notice--success } - - -Magic | What it does ---- | --- -`%writefile` | Saves the contents of a cell to an external file -`%timeit` | Shows how long it takes a cell of code to run -`%who` | List all variables of a global scope -`%store` | Pass variables between notebooks -`%load` | Insert code from an external script - - -
- -## Additional Resources - -* More Jupyter Notebook Overview Material - -
- - diff --git a/_posts/courses/earth-analytics-python/01-science-toolbox/python-open-science-toolbox/2018-02-05-os-05-import-python-packages.md b/_posts/courses/earth-analytics-python/01-science-toolbox/python-open-science-toolbox/2018-02-05-os-05-import-python-packages.md deleted file mode 100644 index 81b3fdc0..00000000 --- a/_posts/courses/earth-analytics-python/01-science-toolbox/python-open-science-toolbox/2018-02-05-os-05-import-python-packages.md +++ /dev/null @@ -1,230 +0,0 @@ ---- -layout: single -deprecated: true -title: 'How to Install Python Packages and Then Use Then in Python' -excerpt: 'The first step in using packages in Python is to install them on your computer. Learn how to install and and import python packages.' -authors: ['Martha Morrissey','Leah Wasser', 'Software Carpentry'] -modified: 2020-02-05 -category: [courses] -class-lesson: ['open-science-python'] -permalink: /courses/earth-analytics-python/python-open-science-toolbox/install-and-import-python-packages/ -nav-title: 'Install and Import Packages' -week: 1 -sidebar: - nav: -author_profile: false -comments: true -order: 5 -course: "earth-analytics-python" -topics: - reproducible-science-and-programming: ['python'] ---- -{% include toc title="In This Lesson" icon="file-text" %} - -This tutorial walks you through how to install and import `Python` packages. - -
- -## Learning Objectives - -At the end of this activity, you will be able to: - -* Explain what a package is in `Python`. -* Install a `Python` package using terminal. - - -## What You Need - -* You will also need to have the earth-analytics-python environment set up. Instructions for setting up this environment are here: Set up earth analytics python environment - -
- -Information below is adapted from materials developed by Anaconda on managing packages: Conda Documentation. - -## What is a Package? - -In `Python`, a package is a bundle of pre-built functionality. You can think of a package like a toolbox filled with tools. The tools in the toolbox can be compared to functions in `Python`. - -When working with Python, the "tools" (i.e. functions) do things like calculate a mathematical operation like a sum or create a plot. There are many different packages available for `Python`. Some of these are optimized for scientific tasks including: - -* Statistics -* Machine learning -* Using geospatial data -* Visualizing data - - -## Where To Get Python Packages - -There are many different repositories where `Python` packages are maintained and from where they can be installed. When installing libraries on your computer or in an online environment, it is important to consider where the package is maintained. - -There are three main python package repositories to download `Python` libraries from: -* **Conda:** this is the default repository that is used and maintained for the Anaconda distribution of `Python`. To install libraries from conda, you use the syntax `conda install` at the command line.. -* **Conda-forge:** Conda-forge is community maintained. We have found that installing many of the spatial packages using conda-forge will minimize conflicts between packages. -* **Pip:** `Python` Package Index (pip) is another way to install `Python` packages. - - **Data Tip:** -Sometimes `Python` libraries are on `Github.com`. You can install `Python` libraries from `Github.com` using `pip install git+git://github.com/path-to-github-user/repo-name.git` -{: .notice--success} - -It is good practice to download as many packages as possible from the same repository. For example, if you use pip to install geopandas and then try to install shapely from conda-forge, the odds of conflicts increase. - -When you encounter these conflicts, often you will not be able to load the libraries and start coding. Conflicts between package dependencies can be frustrating, when all you want to do is start coding, and instead, you need to figure out how to properly install a package. - -For consistency, in this course, you will download most packages from the **conda-forge** repository. - -### Install a Package In a Python Environment - -You can add as many packages as you want to a `Python` environment. However, it is important to keep track of which environment you are adding the package to. If you add the `geopandas` package to your root `Python` environment and then try to use `geopandas` in another environment, it won’t work! - -To add a package, you need to complete the following steps: -1. Open a terminal so you have access to the command line. -2. Activate the `Python` environment that you wish to add the package to. -3. Install the package that you want to add to that environment - -Note, the example code below assumes that you have already setup the `earth-analytics-python` environment. The code below will activate that environment and then add the `statsmodels` package to it. - -Note that you are using conda to install the `statsmodels` package in this example. - - -``` bash - -source activate earth-analytics-python -conda install conda-forge statsmodels - -``` -On Windows: - -``` bash - -activate earth-analytics-python -conda install conda-forge statsmodels - -``` - -Note that you can also install a package to an environment directly using the --name argument. To install a specific library, such as `sciPy`, into an existing environment called “myenv”, you would use the following code: - -```bash - -conda install conda-forge --name myenv sciPy - -``` - -To install the `scipy` library to the `earth-analytics-python` environment, you’d use the code below: - -```bash - -conda install conda-forge --earth-analytics-python scipy - -``` - -Following the examples above, if you do not either specify the environment name, OR activate the environment that you wish to install the package to, then the package installs into the current, active environment. The code below will install a package called `bokeh` into the currently active environment. - -```bash - -conda install conda-forge bokeh - -``` - -If a desired package is not available for installation with conda-forge but is available for installation with conda, you can simply use `conda` rather than `conda-forge` to install a package: - -```bash - -source activate earth-analytics-python -conda install packagename - -``` - - -### View List of All Installed Packages in an Environment - -Sometimes you want to view all of the packages installed in a particular environment. To see the installed packages in the activate environment in the terminal, type: - -``` bash - -conda list - -``` - -The results of `conda list` will show you: -1. What packages are installed -2. What version of each package is installed -3. Where you installed each package from (pip, conda, conda-forge) - -IMPORTANT: note that when you run `conda list`, it is listing packages installed in the current active environment. - -``` -(earth-analytics-python)~ username $ conda list -# packages in environment at //anaconda/envs/earth-analytics-python: -# -affine 2.1.0 py_1 conda-forge -alembic 0.9.7 -altair 1.2.1 py_0 conda-forge -appnope 0.1.0 py36_0 conda-forge -asn1crypto 0.22.0 py36_0 conda-forge -attrs 17.4.0 py_0 conda-forge -backports 1.0 py36_1 conda-forge -backports.functools_lru_cache 1.4 py36_1 conda-forge -blas 1.1 openblas conda-forge -bleach 2.0.0 py36_0 conda-forge -boost 1.65.1 py36_0 conda-forge - -``` - - -## Import a Package in Python - -Once you have installed the packages that you require, you can call them in `Python` at the command line, in a script or in a `Jupyter Notebook` file. You have to explicitly call and load each package that you need in your notebook or script in order for the functions (or tools) in the package to be available in your code. - -You can import `Python` packages using `import package-name`. Once a package has been imported, you can call functions from that package as follows: - -``` -import numpy -numpy.sin(0) -0 -``` - - - -### Package Shortcuts or Aliases - -In the example above, the sin function was called using the full `Python` name: `numpy.sin`. Doing this over and over will make your code more verbose. Thus, you will often see abbreviations or aliases used to call functions within a specific package. The syntax to create an library abbreviation is: - -``` import _____ (name of package) as ____``` - -Using the example above, you can create an abbreviation for the `numpy` package. It is common to use `np` for numpy: - -``` -import numpy as np -numpy.sin(0) -0 -``` - -
- - Jupyter Notebook with code cell to import the Python packages called numpy and pandas using the alias np and pd. -
Jupyter Notebook with code cell to import the Python packages called numpy and pandas using the alias np and pd. -
-
- - -### Import Libraries at the Top of Your Script - -It is good practice to import all of the packages that you will need in the first code cell of a `Jupyter Notebook` file. This allows anyone looking at your code to immediately know what packages they need to run the code. - -
- - Jupyter Notebook with the first code cell importing the numpy package (and many others) to be used with abbreviations or aliases (e.g. np). -
Jupyter Notebook with the first code cell importing the numpy package (and many others) to be used with abbreviations or aliases (e.g. np). -
-
- -Once you have imported all of the packages that you need in your code, you have access to all of the functions contained within each package and you can query for a list of available functions. - -For example, using the alias `np` for `numpy`, you can get a list of the functions available using `np.()` and hitting the tab key. A list of callable functions will appear. - -
- - Jupyter Notebook with a code cell to get a list of the functions available in numpy, which was imported as np. -
Jupyter Notebook with a code cell to get a list of the functions available in numpy, which was imported as np. -
-
diff --git a/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/2020-02-03-spatial-data-applications-landing-page.md b/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/2020-02-03-spatial-data-applications-landing-page.md index 59eee9d9..a58f2c5a 100644 --- a/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/2020-02-03-spatial-data-applications-landing-page.md +++ b/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/2020-02-03-spatial-data-applications-landing-page.md @@ -4,7 +4,7 @@ category: courses title: "Spatial Data Applications in Python" permalink: /courses/use-data-open-source-python/spatial-data-applications/ week-landing: 4 -modified: 2020-02-05 +modified: 2020-02-06 week: 4 sidebar: nav: diff --git a/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty01-understand-uncertainty.md b/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty01-understand-uncertainty.md index 11e9c3f5..2e0cd997 100644 --- a/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty01-understand-uncertainty.md +++ b/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty01-understand-uncertainty.md @@ -4,7 +4,7 @@ title: "Compare Lidar With Human Measured Tree Heights - Remote Sensing Uncertai excerpt: "Uncertainty quantifies the range of values within which the value of the measurement falls - within a specified level of confidence. Learn about the types of uncertainty that you can expect when working with tree height data both derived from lidar remote sensing and human measurements and learn about sources of error including systematic vs. random error." authors: ['Leah Wasser', 'Chris Holdgraf'] dateCreated: 2016-12-06 -modified: 2020-02-05 +modified: 2020-02-06 category: [courses] class-lesson: ['remote-sensing-uncertainty-python-tb'] permalink: /courses/use-data-open-source-python/spatial-data-applications/lidar-remote-sensing-uncertainty/ diff --git a/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty03-summarize-and-compare-measured-to-lidar-data.md b/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty03-summarize-and-compare-measured-to-lidar-data.md index 4c53c399..b0ffd7fa 100644 --- a/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty03-summarize-and-compare-measured-to-lidar-data.md +++ b/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty03-summarize-and-compare-measured-to-lidar-data.md @@ -4,7 +4,7 @@ title: "Compare Lidar to Measured Tree Height" excerpt: "To explore uncertainty in remote sensing data, it is helpful to compare ground-based measurements and data that are collected via airborne instruments or satellites. Learn how to create scatter plots that compare values across two datasets." authors: ['Leah Wasser', 'Chris Holdgraf', 'Carson Farmer'] dateCreated: 2016-12-06 -modified: 2020-02-05 +modified: 2020-02-06 category: [courses] class-lesson: ['remote-sensing-uncertainty-python-tb'] permalink: /courses/use-data-open-source-python/spatial-data-applications/lidar-remote-sensing-uncertainty/summarize-and-compare-lidar-insitu-tree-height/ diff --git a/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty04-regression-and-questioning-your-data.md b/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty04-regression-and-questioning-your-data.md index a0fe3a81..6e89e2d2 100644 --- a/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty04-regression-and-questioning-your-data.md +++ b/_posts/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty04-regression-and-questioning-your-data.md @@ -4,7 +4,7 @@ title: "Use Regression Analysis to Explore Data Relationships & Bad Data" excerpt: "You often want to understand the relationships between two different types of data. Learn how to use regression to determine whether there is a relationship between two variables." authors: ['Max Joseph', 'Leah Wasser'] dateCreated: 2016-12-06 -modified: 2020-02-05 +modified: 2020-02-06 category: [courses] class-lesson: ['remote-sensing-uncertainty-python-tb'] permalink: /courses/use-data-open-source-python/spatial-data-applications/lidar-remote-sensing-uncertainty/compare-lidar-and-measured-tree-height-regression/ @@ -274,7 +274,7 @@ plt.legend() - + diff --git a/config.yml b/config.yml new file mode 100644 index 00000000..28ce7500 --- /dev/null +++ b/config.yml @@ -0,0 +1,161 @@ +version: 2 +jobs: + build: + working_directory: ~/eds-lessons-website + machine: + image: ubuntu-1604:201903-01 + steps: + - checkout + - run: + name: "Set Python Version" + command: pyenv global 3.7.0 + - run: + name: Get latest lesson commit to master branch + working_directory: ~/eds-lessons-website + command: | + # ACMRT -- only looks at changed files, not deleted ones + changed_files=$(git diff-tree --no-commit-id --name-only --diff-filter=ACMRT -r -m HEAD 2>&1) + # get names of changed files + echo "${changed_files} ">> changed_files.txt + # Remove unwanted files from commit and count files changed + python scripts/parse-commit.py + + # Get latest commit message + echo $(git log -1 --pretty=%B) > commit_msg_latest.txt + if [[ -f website_files.txt ]] + then + echo "The following files were modified: " + cat website_files.txt + else + echo "No files were modified in the last commit." + fi + - run: + name: Get removed, renamed, or moved files + working_directory: ~/eds-lessons-website + command: | + deleted_files=$(git diff-tree --no-commit-id --name-only --diff-filter=D -r HEAD 2>&1) + # get names of changed files + echo "${deleted_files} ">> deleted_files.txt + python scripts/parse-deleted.py + ls + - run: + name: Get & print current branch + working_directory: ~/eds-lessons-website + command: | + # get the current branch + echo $(git branch | sed -n -e 's/^\* \(.*\)/\1/p') > current_branch.txt + # Print out current branch + echo "Working on this branch: " + cat current_branch.txt + - run: + name: Clone earthlab.github.io website branch NEW + working_directory: ~/ + command: | + branch=$(head -1 eds-lessons-website/current_branch.txt) + # Only clone eds.org if there are files to commit + if [[ -f ~/eds-lessons-website/website_files.txt ]] || [ -f ~/eds-lessons-website/deleted_files.txt ] + then + if [ "$branch" != "master" ] + then + # check that branch exists on remote earthlab.github.io + branch_status=$(git ls-remote --heads https://${EDS_LESSONS_GITHUB_TOKEN_EL}@github.com/earthlab/earthlab.github.io.git "$branch" | wc -l) + # if branch exists, clone it + if [ $branch_status == 1 ] + then + # clone the remote branch + git clone --depth 1 https://${EDS_LESSONS_GITHUB_TOKEN_EL}@github.com/earthlab/earthlab.github.io.git -b "$branch" + echo "Looks like the branch doesn't exist on the eds.org website, created branch for you." + else + # if the branch doesn't exist, clone master and checkout the branch as a new branch + git clone --depth 1 https://${EDS_LESSONS_GITHUB_TOKEN_EL}@github.com/earthlab/earthlab.github.io.git + cd earthlab.github.io + git checkout -b "$branch" + fi + else + # if commits are on master, push to website-autobuild to avoid direct commits to live website + # check for autobuild branch on website remote + branch_status=$(git ls-remote --heads https://${EDS_LESSONS_GITHUB_TOKEN_EL}@github.com/earthlab/earthlab.github.io.git "website-autobuild" | wc -l) + # if branch exists check it out... + if [ $branch_status == 1 ] + then + # clone the remote branch + git clone -b website-autobuild --depth 1 https://${EDS_LESSONS_GITHUB_TOKEN_EL}@github.com/earthlab/earthlab.github.io.git + else + # if it does not, clone master and checkout a new branch + git clone --depth 1 https://${EDS_LESSONS_GITHUB_TOKEN_EL}@github.com/earthlab/earthlab.github.io.git + cd earthlab.github.io + git checkout -b website-autobuild + fi + fi + + # Only Copy files to the live website repo if there are files to move + # This might be nice as it's own step. + if [[ -f website_files.txt ]] + then + cd ~/eds-lessons-website + python scripts/move-files.py + fi + else + echo "There are no changes, not cloning the website repo." + fi + pwd + - run: + name: Delete removed/renamed/moved images from .io website + working_directory: ~/eds-lessons-website + command: | + if [[ -f deleted_image_files.txt ]] + then + echo -e "Deleting the following images:" + cat deleted_image_files.txt | while read line + do + echo $line + image_to_delete=~/earthlab.github.io/$line + rm $image_to_delete + done + else + echo "There are no images to remove in this PR!" + fi + - run: + name: Delete removed/renamed/moved markdown files and associated image directories from .io website + working_directory: ~/eds-lessons-website + command: | + ls + if [[ -f deleted_md_files.txt ]] + then + echo -e "Deleting the following notebooks and their images:" + cat deleted_md_files.txt | while read line + do + echo $line + post_to_delete=~/earthlab.github.io/$line + rm $post_to_delete + echo "$post_to_delete" + # clear images dir associated with post + image_dir_to_delete=~/earthlab.github.io/images/${line%.*} + rm -rf $image_dir_to_delete + echo "$image_dir_to_delete" + done + else + echo "There are no lessons and associated lesson images to remove in this PR!" + fi + - run: + name: Push changes in files and images to earthlab.github.io repo + working_directory: ~/earthlab.github.io + command: | + if [[ -f ~/eds-lessons-website/website_files.txt ]] || [ -f ~/eds-lessons-website/deleted_files.txt ] + then + # Be sure to see how many files there are and only commit if there are more than 0 + git status + git config credential.helper 'cache --timeout=120' + git config user.email "earth.lab@colorado.edu" + git config user.name "Deployment Bot" + OUTPUT=$( GIT_PAGER_IN_USE=true git status ) + echo "$OUTPUT" + git add . + # get current commit message + commit_msg_latest=$(head -1 ~/eds-lessons-website/commit_msg_latest.txt) + git commit --allow-empty -m "$commit_msg_latest" + # Push quietly to prevent showing the token in log + git push -q https://${EDS_LESSONS_GITHUB_TOKEN_EL}@github.com/earthlab/earthlab.github.io.git + else + echo "Nothing to commit as there were no changes" + fi diff --git a/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-02-flood-drivers/2018-02-05-coflood-02-flood-drivers_3_0.png b/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-02-flood-drivers/2018-02-05-coflood-02-flood-drivers_3_0.png deleted file mode 100644 index 8274aeaa..00000000 Binary files a/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-02-flood-drivers/2018-02-05-coflood-02-flood-drivers_3_0.png and /dev/null differ diff --git a/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-03-flood-drivers-precipitation/2018-02-05-coflood-03-flood-drivers-precipitation_3_0.png b/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-03-flood-drivers-precipitation/2018-02-05-coflood-03-flood-drivers-precipitation_3_0.png deleted file mode 100644 index ba0be0ee..00000000 Binary files a/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-03-flood-drivers-precipitation/2018-02-05-coflood-03-flood-drivers-precipitation_3_0.png and /dev/null differ diff --git a/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-03-flood-drivers-precipitation/2018-02-05-coflood-03-flood-drivers-precipitation_5_0.png b/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-03-flood-drivers-precipitation/2018-02-05-coflood-03-flood-drivers-precipitation_5_0.png deleted file mode 100644 index 1dc613a0..00000000 Binary files a/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-03-flood-drivers-precipitation/2018-02-05-coflood-03-flood-drivers-precipitation_5_0.png and /dev/null differ diff --git a/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-03-flood-drivers-precipitation/2018-02-05-coflood-03-flood-drivers-precipitation_7_0.png b/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-03-flood-drivers-precipitation/2018-02-05-coflood-03-flood-drivers-precipitation_7_0.png deleted file mode 100644 index b5312eb2..00000000 Binary files a/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-03-flood-drivers-precipitation/2018-02-05-coflood-03-flood-drivers-precipitation_7_0.png and /dev/null differ diff --git a/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-04-terrain-impacts/2018-02-05-coflood-04-terrain-impacts_3_0.png b/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-04-terrain-impacts/2018-02-05-coflood-04-terrain-impacts_3_0.png deleted file mode 100644 index 092ecf3f..00000000 Binary files a/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-04-terrain-impacts/2018-02-05-coflood-04-terrain-impacts_3_0.png and /dev/null differ diff --git a/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-04-terrain-impacts/2018-02-05-coflood-04-terrain-impacts_5_0.png b/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-04-terrain-impacts/2018-02-05-coflood-04-terrain-impacts_5_0.png deleted file mode 100644 index edaa51e0..00000000 Binary files a/images/courses/earth-analytics-python/01-science-toolbox/intro-2013-floods/2018-02-05-coflood-04-terrain-impacts/2018-02-05-coflood-04-terrain-impacts_5_0.png and /dev/null differ diff --git a/images/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty01-understand-uncertainty/2016-12-06-uncertainty01-understand-uncertainty_23_0.png b/images/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty01-understand-uncertainty/2016-12-06-uncertainty01-understand-uncertainty_23_0.png index df5bad29..587d29f9 100644 Binary files a/images/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty01-understand-uncertainty/2016-12-06-uncertainty01-understand-uncertainty_23_0.png and b/images/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty01-understand-uncertainty/2016-12-06-uncertainty01-understand-uncertainty_23_0.png differ diff --git a/images/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty04-regression-and-questioning-your-data/2016-12-06-uncertainty04-regression-and-questioning-your-data_18_1.png b/images/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty04-regression-and-questioning-your-data/2016-12-06-uncertainty04-regression-and-questioning-your-data_18_1.png index 9cfe1676..c93bb968 100644 Binary files a/images/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty04-regression-and-questioning-your-data/2016-12-06-uncertainty04-regression-and-questioning-your-data_18_1.png and b/images/courses/intermediate-earth-data-science-textbook/04-spatial-data-applications/remote-sensing-uncertainty/2016-12-06-uncertainty04-regression-and-questioning-your-data/2016-12-06-uncertainty04-regression-and-questioning-your-data_18_1.png differ diff --git a/scripts/move-files.py b/scripts/move-files.py new file mode 100644 index 00000000..59baefc4 --- /dev/null +++ b/scripts/move-files.py @@ -0,0 +1,40 @@ +""" +This script takes a set of files from a text file, and line by line parses and +moves them to the corresponding directory. + +It is used to move files in the website repo to the eds.org live website. +This script assumes that it is being run in the website repo. +""" + +import os +import shutil + +# get absolute path +cwd = os.path.abspath(os.getcwd()) +# create full path to other repo +eds_website_repo = cwd.replace("eds-lessons-website", "earthlab.github.io") + +changed_files = "website_files.txt" + +# Open the text file and move files over to the other dir +fp = open(changed_files, 'r') + +if os.stat(changed_files).st_size == 0: + print("There are no changes to move.") +# Loop through each file, clean the path and move to the final directory +else: + for f in fp: + print("Trying to move: ", f) + f = f.rstrip('\n').strip() + if not f.lower().endswith(('yml', 'py')): + print("final file name: ", f) + new_path = os.path.join(eds_website_repo, f) + dir_path = os.path.dirname(new_path) + if not os.path.exists(dir_path): + os.makedirs(dir_path) + shutil.copy(f, new_path) + print("File has been moved to: ", new_path) + + + + diff --git a/scripts/parse-commit.py b/scripts/parse-commit.py new file mode 100644 index 00000000..0e92ac1f --- /dev/null +++ b/scripts/parse-commit.py @@ -0,0 +1,21 @@ +""" +This script reads every line of "changed_files.txt" and extracts only the files +that should be moved to the live website. If there are files to commit, it +creates a website_files.txt file that is used to store the files to move. + +Files are moved in the move-files.py script +""" + +with open("changed_files.txt") as f: + content = f.readlines() +content = [x.rstrip('\n').strip() for x in content] + + +website_files = [line for line in content if not line.endswith((".py", "yml"))] + +if len(website_files) > 0: + with open("website_files.txt", "w") as f: + if len(website_files) > 0: + for count, fn in enumerate(website_files): + f.write("%s\n" % fn) + diff --git a/scripts/parse-deleted.py b/scripts/parse-deleted.py new file mode 100644 index 00000000..5dad8216 --- /dev/null +++ b/scripts/parse-deleted.py @@ -0,0 +1,25 @@ +''' +This script reads every line of "deleted_files.txt" and stores each line as an element in a list +From this list, we then parse out .ipynb files, .Rmd files, and image files (.jpg, .jpeg, .gif) +''' + +with open("deleted_files.txt") as f: + content = f.readlines() +content = [x.strip() for x in content] + +deleted_md_files = [line for line in content if line.endswith(".md")] +deleted_image_files = [line for line in content if line.endswith(".jpg") or line.endswith(".jpeg") or line.endswith(".gif") or line.endswith(".png")] + +print("deleted notebooks: ", deleted_md_files) +print("deleted image files: ", deleted_image_files) + + +with open("deleted_md_files.txt", "w") as f: + if len(deleted_md_files) > 0: + for fn in deleted_md_files: + f.write("%s\n" % fn) + +with open("deleted_image_files.txt", "w") as f: + if len(deleted_image_files) > 0: + for fn in deleted_image_files: + f.write("%s\n" % fn)