File:Air density vs temperature.svg

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikipedia, the free encyclopedia

Original file(SVG file, nominally 575 × 431 pixels, file size: 51 KB)

Summary

Description
English: Air density vs. Temperature graph with exponential and 2nd-order polynomial trends. Data from w:en:Density#Air
Date
Source Own work
Author T.seppelt
SVG development
InfoField
 
The SVG code is valid.
 
This plot was created with Matplotlib.
Source code
InfoField

Python code

import csv, numpy,scipy,scipy.optimize
import matplotlib.pyplot as plt
x = []
y = []
with open("data.csv", "r") as f:
    for line in csv.DictReader(f, fieldnames=['x','y'], delimiter=';'):
        x.append(int(line['x']))
        y.append(float(line['y']))
x = numpy.array(x)
y = numpy.array(y)

intx = numpy.linspace(min(x), max(x), 100)
P1 = numpy.poly1d(numpy.polyfit(x, y, 2))

P2_data = scipy.optimize.curve_fit(lambda t,a,b: a*numpy.exp(b*t),  x,  y, )[0]
P2 = lambda x : P2_data[0]*numpy.exp(P2_data[1]*x)

plt.scatter(x,y, label="Density of air at 1 atm pressure")
plt.plot(intx, P1(intx), label = "Polynomial Trend\n$x \mapsto 10^{{-5}} x^2 {}x+{}$".format(*numpy.round(P1,4)[1:]))
plt.plot(intx, P2(intx), label = "Exponential Trend\n$x \mapsto \exp({}x) {} $".format(* numpy.round(P2_data,4)))
plt.legend()
plt.xlabel("Temperature [°C]")
plt.ylabel("Density [kg/m³]")
plt.title("Air density vs. temperature")
plt.savefig("output.svg",format="svg",transparent=True)

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

4 October 2017

image/svg+xml

3601a048d9e63a3feafa761bebc0519aa232b853

52,577 byte

431 pixel

575 pixel

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current11:09, 5 October 2017Thumbnail for version as of 11:09, 5 October 2017575 × 431 (51 KB)T.seppeltexp as function without exponent
07:55, 4 October 2017Thumbnail for version as of 07:55, 4 October 2017575 × 431 (51 KB)T.seppeltUser created page with UploadWizard
The following pages on the English Wikipedia use this file (pages on other projects are not listed):

Global file usage

The following other wikis use this file:

Metadata