[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math

Search:


View post   

>> No.15585550 [View]
File: 35 KB, 1000x600, avg_latitude_per_year.png [View same] [iqdb] [saucenao] [google]
15585550

Can we finally stop posting this "percentage of stations" bullshit now?
You'll find the data here: https://www.ncei.noaa.gov/pub/data/ghcn/daily/ghcnd-inventory.txt
Not that OP's image says which types of stations he uses and whatnot, so I just counted all of them. Code by ChatGPT because it's easy enough:


import pandas as pd
import matplotlib.pyplot as plt

# Define column names
columns = ['ID', 'Latitude', 'Longitude', 'Type', 'StartYear', 'EndYear']

# Load data from .txt file into pandas DataFrame
df = pd.read_csv('ghcnd-inventory.txt', delim_whitespace=True, names=columns)

# Create an empty DataFrame to store average latitude per year
avg_latitude = pd.DataFrame(columns=['Year', 'AvgLatitude'])

# Define the range of years to consider
start_year = 1900
end_year = 2023

# Iterate through the unique start and end years in the original DataFrame
for year in range(start_year, end_year + 1):
# Filter rows that are active in the current year
active_rows = df[(df['StartYear'] <= year) & (df['EndYear'] >= year)]

# Calculate average latitude
avg_lat = active_rows['Latitude'].mean()

# Append the year and the average latitude to the new DataFrame
avg_latitude = avg_latitude.append({'Year': year, 'AvgLatitude': avg_lat}, ignore_index=True)

# Plotting
plt.figure(figsize=(10, 6))
plt.plot(avg_latitude['Year'], avg_latitude['AvgLatitude'])
plt.title('Average Latitude per Year')
plt.xlabel('Year')
plt.ylabel('Average Latitude')
plt.grid(True)
plt.savefig('avg_latitude_per_year.png')

Navigation
View posts[+24][+48][+96]