Public
Edited
Feb 8, 2024
Insert cell
Insert cell
Insert cell
Insert cell
weatherDT.view(10)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
tempStatuses.view()
Insert cell
tempStatuses
.groupby('period', 'city')
.rollup({
t_avg: d => op.mean(d.t_avg),
})
.filter(
aq.escape((obs) => obs.period != 'junk')
)
.groupby('city')
.pivot('period', 't_avg')
.derive({
temp_diff: aq.escape((obs) => obs.now - obs.reference)
})
.orderby(aq.desc('temp_diff'))
.view()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
extremeDaysChange.view()
Insert cell
extremeDaysChange.objects()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
aq.from(seasonsData).view()
Insert cell
Insert cell
Insert cell
aq.from(seasonsData)
.groupby('yearGroup', 'city', 'calendarSeason', 'avgTempGroup2')
.count()
.groupby('yearGroup', 'city', 'calendarSeason')
.pivot('avgTempGroup2', 'count')
.objects()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
seasonPercentsMonth.view()
Insert cell
seasonPercentsMonth.objects()
Insert cell
Insert cell
weatherDT.view()
Insert cell
Insert cell
refPeriodPrecip.view()
Insert cell
Insert cell
aq.from(extremePrecipDays)
.view()
Insert cell
Insert cell
Insert cell
weatherDT.view()
Insert cell
Insert cell
Insert cell
Insert cell
precipDaysType = weatherDT
.derive({
yearGroup: aq.escape((obs) => {
for (let i = 0; i < yearStarts.length; i++) {
if ((obs.year >= yearStarts[i]) && (obs.year < yearStarts[i] + yearsGroupLen))
return yearStarts[i]
}
})
})
.filter(
aq.escape((obs) => obs.precip_sum >= 1)
)
.filter(
aq.escape((obs) => obs.hours_precip_01mm >= 6)
)
.derive({
precip_type_by_sum_name: aq.escape((obs) => {
if (obs.precip_type_by_sum == 1)
return "дождь"
else if (obs.precip_type_by_sum == 2)
return "дождь и cнег"
else if (obs.precip_type_by_sum == 3)
return "cнег"
})
})
.groupby('year', 'city', 'yearGroup', 'precip_type_by_sum_name')
.count()
.groupby('yearGroup', 'city', 'precip_type_by_sum_name')
.rollup({
count: d => op.mean(d.count),
})
// .groupby('yearGroup', 'city')
// .pivot('precip_type_by_sum_name', 'count')
.objects()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
total_precip_sum_by_seasons = weatherDT
.derive({
yearGroup: aq.escape((obs) => {
for (let i = 0; i < yearStarts.length; i++) {
if ((obs.year >= yearStarts[i]) && (obs.year < yearStarts[i] + yearsGroupLen))
return yearStarts[i]
}
}),
period: aq.escape((obs) => {
if ((obs.year >= 1950) & (obs.year < 1980))
return 'reference'
else if (obs.year >= 2014)
return 'now'
else
return 'junk'
})
})
.select('city', 'date', 'yearGroup', 'year', 'season', 'precip_sum', 'period')
.groupby(['city', 'yearGroup', 'year', 'season', 'period'])
.rollup({
precip_sum: d => op.sum(d.precip_sum),
})
.groupby(['city', 'season', 'period'])
.rollup({
avg_precip_sum: d => op.mean(d.precip_sum),
})
.view()
Insert cell
Insert cell
Plot.plot((() => {
const n = 4; // number of facet columns
const keys = Array.from(d3.union(precip_sum_by_seasons.map((d) => d.city)));
const index = new Map(keys.map((key, i) => [key, i]));
const fx = (key) => index.get(key) % n;
const fy = (key) => Math.floor(index.get(key) / n);
return {
height: 550,
width: 1200,
axis: null,
y: {insetTop: 20},
fx: {padding: 0.02},
marks: [
Plot.barY(precip_sum_by_seasons, {
x: "yearGroup",
y: "avg_precip_sum",
fx: "city",
fy: "season",
opacity: 0.6,
channels: {
avg_precip_sum: {
value: "avg_precip_sum",
label: "avg_precip_sum sum"
},
yearGroup: "yearGroup",
city: "city",
season: "season"
},
tip: {
format: {
x: false,
y: false,
fx: false,
fy: false,
yearGroup: (d) => (`${d}`)
}
}
}),
Plot.axisY({
tickSpacing: 20,
nice: true,
label: "мм"
}),

Plot.axisX({
tickSize: 0,
tickSpacing: 120,
label: null,
tickFormat: (d) => {if (getUniformlyDistributedElements(yearStarts, 5).includes(d))
return `${d}`
else
return ""}
}),

// подписи городов
// Plot.text(keys, {fx, fy, frameAnchor: "top-left", dx: 6, dy: 6})
]
};
})())
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
new_year_data.view()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
snowyDatesDecades
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
snowyDatesPeriodsBase.filter(
aq.escape((obs) => obs.firstStableSnowDays < 300)
)
.groupby('period', 'city')
.rollup({
count: d => op.mean(d.firstStableSnowDays),
})
.derive({
avg_date: aq.escape((obs) => {
var fillYear = 2020
var new_date = new Date(new Date(fillYear, 6, 1).getTime() + parseInt(obs.count) * 60 * 60 * 24 * 1000)

if (obs.count > 300)
return null

if (new_date.getMonth() > 8)
return new Date(2020, new_date.getMonth(), new_date.getDate()).toLocaleString()
else
return new Date(2021, new_date.getMonth(), new_date.getDate()).toLocaleString()
})
})
.filter(
aq.escape((obs) => obs.period != 'junk')
)
// .filter(
// aq.escape((obs) => obs.city != 'Краснодар' & obs.city != 'Ростов-на-Дону')
// )
.groupby('city')
.pivot(['period'], ['count', 'avg_date'])
.objects()
Insert cell
snowyDatesPeriodsBase.filter(
aq.escape((obs) => obs.firstStableSnowDays >= 300)
)
.groupby('period', 'city')
.rollup({
bad_years: d => op.count(),
})
.filter(
aq.escape((obs) => obs.period != 'junk')
)
.view()
Insert cell
Insert cell
aq.from(snowSize).view()
Insert cell
snowSize
Insert cell
Insert cell
Insert cell
snowDT.view()
Insert cell
Insert cell
aq.from(snowDays).view()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function getSeason(date) {

let month = date.getMonth();
if (month >= 2 && month <= 4)
return 'весна'
else if (month >= 5 && month <= 7)
return 'лето';
else if (month >= 8 && month <= 10)
return 'осень';
else
return 'зима';

}
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more