Skip to content

Instantly share code, notes, and snippets.

View mikkohei13's full-sized avatar

Mikko Heikkinen mikkohei13

View GitHub Profile
@mikkohei13
mikkohei13 / ai-model-comparison-set3.csv
Created July 7, 2023 18:35
Comparison of Naturalis and iNaturalist species recognition models.
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
File unique identifier;Prediction by Naturalis;Probability by Naturalis;True or false by Naturalis;Prediction by iNat;Probability by iNat;True or false by iNat
_test_set_3/(Acanthosomatidae) Elasmucha grisea Parent Bug_8.jpg;Elasmucha grisea;0.894348;1;Elasmucha grisea;0.314679;1
_test_set_3/(Aphrophoridae) Aphrophora alni_3.jpg;Aphrophora alni;1;1;Aphrophora alni;0.410643;1
_test_set_3/(Cercopidae) Cercopis vulnerata_2.jpg;Cercopis vulnerata;1;1;Cercopis vulnerata;0.460223;1
_test_set_3/(Cicadellidae) Adarrus ocellaris_3.jpg;Errastunus ocellaris;0.973848;0;Speudotettix subfusculus;0.303513;0
_test_set_3/(Cicadellidae) Aguriahana stellulata_4.jpg;Aguriahana stellulata;0.999827;1;Aguriahana;0.433531;1
_test_set_3/(Cicadellidae) Arthaldeus pascuellus_4.jpg;Arthaldeus pascuellus;1;1;Graminella nigrifrons;0.347305;0
_test_set_3/(Cicadellidae) Athysanus argentarius_5.jpg;Athysanus argentarius;0.999749;1;Athysanus argentarius;0.491078;1
_test_set_3/(Cicadellidae) Batracomorphus irroratus_5.jpg;Iassus lanio;0.699501
@mikkohei13
mikkohei13 / forecast_species.py
Created August 25, 2023 09:24
Estimate future observation counts based on laji.fi data
import json
from statsmodels.tsa.holtwinters import Holt
# Load the JSON data
with open("pyjamalude-years.json", "r") as file:
data = json.load(file)
'''
Estimate future observation counts based on laji.fi data
@mikkohei13
mikkohei13 / process-named-places.py
Created October 13, 2023 11:10
Convert FinBIF named places file (line transects) into geojson
import json
def process_geojson_with_properties(input_filename, output_filename):
# Load the JSON file
with open(input_filename, "r") as file:
data = json.load(file)
# Extract all items under "results"
results = data.get("results", [])
@mikkohei13
mikkohei13 / convert.py
Created October 24, 2023 11:02
Convert eBird GBIF simple archive to multiple DwC files for FinBIF ETL import
import pandas as pd
import numpy as np
import re
# Mikko Heikkinen 2020, 2022, 2023
# Defines which columns to use. Order is not significant.
usecols = [
'gbifID',
@mikkohei13
mikkohei13 / citations.py
Created November 16, 2023 14:41
Fetch article citation counts based on DOI's from opencitations.net API
# Made with ChatGPT/GPT-4
import requests
import pandas as pd
import time
import csv
def fetch_citation_count(doi):
"""
Function to fetch the citation count for a given DOI using the OpenCitations API.
@mikkohei13
mikkohei13 / temporal_outliers.py
Created November 23, 2023 21:13
Find temporal outliers in FinBIF simple datafile
# Made with ChatGPT GPT-4 2023-11-23
# Finds temporal outliers from a simple occurrence data file of a single species from FinBIF, with headers in English.
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from shapely.geometry import Point
import geopandas as gpd
# Load the data
@mikkohei13
mikkohei13 / spatial_outliers.py
Created November 24, 2023 12:04
Find spatial outliers from FinBIF simple data format
# Made wth ChatGPT / GPT-4
# Finds spatial ouliers by clcularing SD of locations
# Input: FinBIF data of a single species in simple data format
import pandas as pd
import numpy as np
# Load the data (Replace 'file_path' with your actual file path)
file_path = 'your_data_file.csv' # Change this to your file path
bird_data = pd.read_csv(file_path, sep='\t')
@mikkohei13
mikkohei13 / convert.py
Created December 29, 2023 11:16
Convert Luke atlas dataset to FinBIF Data Bank format
'''
Converts "Luken aineistokooste 4. lintuatlakseen" tsv file into FinBIF Data Bank secondary data format.
Mikko Heikkinen 2023-12-29
'''
import pandas as pd
# Load the file into a Pandas dataframe using tab as the delimiter. Keep "NA" as a value.
file_path = 'luke_atlasdata.txt'
@mikkohei13
mikkohei13 / atlas-tiira.py
Last active January 22, 2024 18:49
Tool to compare data from bird atlas and Tiira, to see which species & observations are missing breeding index.
'''
Tool to compare observations from Tiira to atlas data, to see which observations could increase breeding indices.
MIT License
'''
# Source data - Tiira export saved as UTF-8 CSV file
tiira_filename = "./import/tiira.csv"
# Atlas square to compare to
atlas_square = "667:337"
@mikkohei13
mikkohei13 / oma_riista_conversions.py
Last active January 13, 2025 21:16
Script to convert CSV tabular file to FinBIF data bank format
"""
Script to make conversions to a CSV tabular file containing bird species observations (occurrence records)
Updated for 2024 file format
Data format sample:
id;pvm;aika;laji;lkm;ykj_p;ykj_i;PV-indeksi
1593921;01.02.2024;07:16;teeri;1;6890000;3410000;2
1593922;01.02.2024;08:04;metso;1;7070000;3380000;2
1593925;01.02.2024;08:17;metso;1;6980000;3230000;2
1593941;01.02.2024;10:39;teeri;80;7090000;3470000;2