<jupyter_start><jupyter_text>MEGI001-2101033 Introduction to Earth System Data Task 6.2 - Data Handling Analysis (2-D)Created on: Jan 24, 2019 by <NAME>   T6.2 change histogram bin* please produce histograms of the above topography over Europe using different bins.* Considering that the resolution of the topography is about 1.8 km, how much is the area of the imaged part of europe and africa between 0 and 1000 meters of altitude in square kilometers?<jupyter_code># -*- coding: utf-8 -*-
"""
Created on Jan 24 2019

@author: <NAME>, <NAME>
"""

# Import relevant libraries
import numpy as np
import xarray as xr
import netCDF4

from matplotlib import pyplot as plt
from PIL import Image
from scipy.interpolate import griddata

# fname = 'http://thredds.ucar.edu/thredds/dodsC/grib/NCEP/GFS/Global_onedeg/Best'  # Remote OPeNDAP Dataset 
filename = '../assets/data/geospatial-raster/etopo1.nc'   # Local NetCDF file

# f = netCDF4.Dataset(filename)

f = xr.open_dataset(filename)
# # dsloc = ds.sel(lon=230.5,lat=55.0,method='nearest')

for v in f.variables: print(v)
print(f.Band1.data)
#plotting
plt.imshow(f.Band1.data)
plt.show()
flipped = np.flipud(f.Band1.data)# it's flipped!
#plotting
plt.imshow(flipped)
plt.show()
print("minumum latitude is: ", min(f.Band1.lat.values))

print("maximum latitude is: ", max(f.Band1.lat.values))

print("minumum longitude is: ", min(f.Band1.lon.values))

print("maximum longitude is: ", max(f.Band1.lon.values))

minlon = min(f.Band1.lon.values)
maxlon = max(f.Band1.lon.values)
minlat = min(f.Band1.lat.values)
maxlat = max(f.Band1.lat.values)
# plot with legend, x an y axis labels
fig, ax = plt.subplots()
#Ticks for y-axis (latitude)
ax.axes.yaxis.set_ticks([0,flipped.shape[0]])
ax.axes.yaxis.set_ticklabels([maxlat,minlat])
plt.ylabel('Latitude')
#Ticks for x-axis (latitude)
ax.axes.xaxis.set_ticks([0,flipped.shape[1]])
ax.axes.xaxis.set_ticklabels([minlon,maxlon])
plt.xlabel('Longitude')
plt.imshow(flipped)
plt.colorbar()

plt.show()
# plot with legend, x an y axis labels
fig, ax = plt.subplots()
# plt.imshow(flipped, cmap='rainbow')
plt.imshow(flipped, cmap='magma')
# plt.imshow(flipped, cmap='viridis') # the default one from above
plt.colorbar()
#Ticks for y-axis (latitude)
ax.axes.yaxis.set_ticks([0,flipped.shape[0]])
ax.axes.yaxis.set_ticklabels([maxlat,minlat])
plt.ylabel('Latitude')
#Ticks for x-axis (latitude)
ax.axes.xaxis.set_ticks([0,flipped.shape[1]])
ax.axes.xaxis.set_ticklabels([minlon,maxlon])
plt.xlabel('Longitude')
plt.show()
# histogramm of plot
plt.hist(flipped.ravel(), bins=10, range=(-6000, 6000), fc='k', ec='k')
plt.xlabel('Height above mean sea level')
plt.ylabel('Number of pixels')
plt.show()
# histogramm of plot
plt.hist(flipped.ravel(), bins=20, range=(0, 1000), fc='k', ec='k')
plt.xlabel('Height above mean sea level')
plt.ylabel('Number of pixels')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15280665280665282, 'fraction_numerical': 0.028066528066528068, 'mean_word_length': 5.473094170403588, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '62862', 'license': 'MIT', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1103, 'n_words': 263, 'path': 'notebooks/task_6/florent-ralph_task6.2.ipynb', 'repo_name': 'ralflorent/owm', 'size': '2906'}