diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 605f39b..cfc907b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,9 +24,9 @@ jobs: - name: Download occurrence data run: julia --project scripts/get_occurrences.jl - name: Upload occurrence data - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2 with: - name: occurrence_data + name: project_data path: occurrences.csv draw_the_figure: needs: [get_data] @@ -44,29 +44,25 @@ jobs: - name: Donwload occurrence data uses: actions/download-artifact@v2 with: - name: occurrence_data + name: project_data - name: Make the figure run: python scripts/make_plot.py - name: Upload map - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2 with: - name: map + name: project_data path: map.png publish_webpage: needs: [get_data, draw_the_figure] runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' steps: - name: Checkout uses: actions/checkout@v2 - - name: Download occurrence data - uses: actions/download-artifact@v2 - with: - name: occurrence_data - path: dist - - name: Download map + - name: Download data uses: actions/download-artifact@v2 with: - name: map + name: project_data path: dist - name: Deploy the webpage from the dist folder uses: peaceiris/actions-gh-pages@v3 diff --git a/Project.toml b/Project.toml index bbdd196..19a023e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,3 +1,4 @@ [deps] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" +"DataFramesMeta" = "1313f7d8-7da2-5740-9ea0-a2ca25f37964" diff --git a/scripts/get_occurrences.jl b/scripts/get_occurrences.jl index 87a846b..96eb0c0 100644 --- a/scripts/get_occurrences.jl +++ b/scripts/get_occurrences.jl @@ -1,5 +1,6 @@ import GBIF using DataFrames +using DataFramesMeta import CSV @@ -16,21 +17,12 @@ GBIF.occurrences!(occ) GBIF.occurrences!(occ) GBIF.occurrences!(occ) -raw_data = DataFrame(occ) +data = @linq DataFrame(occ) |> + where(:rank .== "SPECIES") |> + select([:name, :longitude, :latitude]) |> + where(:name .∈ ["Amphiprion ".*["melanopus", "ocellaris", "clarkii"]]) |> + where(:longitude .> 0.0) + -# JUDGE NOT LEST YE BE JUDGED -raw_data = raw_data[raw_data.rank .== "SPECIES", :] -# Seriously -ok_names = "Amphiprion ".*["melanopus", "ocellaris", "clarkii"] -# It's 10pm -ok_index = map(f -> in(f, ok_names), raw_data.name) -# I'm so tired -raw_data = raw_data[ok_index, :] -# Can 2020 be over yet, please? -raw_data = raw_data[raw_data.longitude.>=0.0, :] -# I really should have used Query.jl or DataFramesMeta.jl is what I'm trying to say - -# Save only the columns we care about -data = select(raw_data, [:name, :longitude, :latitude]) CSV.write("occurrences.csv", data; writeheader=true)