Atmopy Unit 1

36 flashcardsby MiriE
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
What tool is commonly used to manage Python environments for scientific computing?
Miniconda
2
What is the purpose of creating a virtual environment in Python?
To isolate dependencies and avoid conflicts between projects
3
What command activates a Conda environment named atmopy?
conda activate atmopy
4
What does the 'if' statement do in Python?
It runs a block of code only if a specified condition is true
5
What type of loop runs while a condition is true?
while loop
6
What type of loop runs over items in a list or range?
for loop
7
What is a Python function?
A reusable block of code that performs a specific task
8
How do you define a function in Python?
Using the def keyword
9
What are variables in Python?
Containers that store data values
10
What are the three basic Python data types?
int, float, and str
11
What is a list in Python?
An ordered collection of items that can be changed
12
What is a tuple in Python?
An ordered collection of items that cannot be changed
13
What is a dictionary in Python?
A collection of key-value pairs
14
What is a Python script?
A file containing Python code that can be run as a program
15
What is a docstring?
A string placed at the beginning of a function or module that describes what it does
16
Why are docstrings useful?
They help document code and show up in help() and IDE tooltips
17
What does PEP8 refer to?
The official style guide for writing Python code
18
What is a modular script?
A script designed with separate, reusable components or functions
19
How do you write a comment in Python?
With a # symbol at the beginning of the line
20
How do you get input from a user in Python?
Using the input() function
21
How do you write code that calculates the average 2-meter temperature across all times and locations?
t2m.mean()
22
How do you write code that finds the hour with the strongest average wind speed across a grid?
np.argmax(np.sqrt(u10**2 + v10**2).mean(axis=(1,2)))
23
How do you write code that calculates total daily precipitation from hourly values in a 3D array?
tp.sum()
24
How do you write code that finds the gridpoint with the maximum surface pressure?
np.unravel_index(np.argmax(sp), sp.shape)
25
How do you write code that filters for all humidity values above 70%?
humidity[humidity > 70]
26
How do you write code that converts a temperature array from Kelvin to Celsius?
t2m - 273.15
27
How do you write code that creates a function to convert m/s to km/h for a NumPy array?
def ms_to_kmh(arr): return arr * 3.6
28
How do you write code that calculates wind speed from u and v components?
np.sqrt(u10**2 + v10**2)
29
How do you write code that calculates wind direction (meteorological) from u and v components?
np.arctan2(-u10, -v10) * 180 / np.pi
30
How do you write code that returns the average wind speed for each hour in a 3D array?
np.sqrt(u10**2 + v10**2).mean(axis=(1,2))
31
How do you write code that finds all time steps with total precipitation > 10 mm?
np.where(tp.sum(axis=(1,2)) > 10)
32
How do you write code that averages temperature across time but keeps lat/lon structure?
t2m.mean(axis=0)
33
How do you write code that averages temperature across lat/lon to get a time series?
t2m.mean(axis=(1,2))
34
How do you write code that labels high cloud cover (>60%) as 'cloudy' and others as 'clear'?
np.where(cloud > 60, 'cloudy', 'clear')
35
How do you write code that builds a reusable function to calculate average humidity?
def avg_humidity(arr): return arr.mean()
36
How do you write code that documents a function that returns max wind and the hour it occurs?
def max_wind(ws): """Return max wind and time index."""; return ws.max(), np.argmax(ws)
Study all 36 cards for free