Velocer › फ़्लैशकार्ड › University of Wisconsin–Madison › AOS 573: Computational Methods · UW-Madison
AOS 573: Computational Methods · UW-Madison
Made these while studying for AOS 573. covers most of what we went over in lecture. · quiet_kernel द्वारा · 103 कार्ड्स
- What does the Git rebase workflow accomplish?It integrates changes from one branch into another by reapplying commits, producing a clean, linear history.
- Why are area-weighted global means necessary for gridded climate data?Grid cells vary in area (especially with latitude), so weighting by cell area avoids bias in global averages.
- What is cmocean used for?Providing perceptually uniform colormaps designed for oceanographic and atmospheric data.
- What does xarray provide for climate data analysis?Labeled multidimensional arrays that make working with NetCDF gridded datasets easier.
- What is the difference between tabular and gridded data in this context?Tabular data is organized in rows/columns (e.g., cruise measurements, indices), while gridded data is multidimensional arrays on a spatial grid (e.g., NetCDF climate fields).
- What is the main benefit of using git pull --rebase instead of a regular pull?It maintains a clean linear history without creating merge commits.
- What should you do with local changes before running git pull --rebase?Stage and commit them first, so your work can be replayed on top of upstream updates.
- What does rebasing do with your local commits during a pull?It replays them on top of the updated upstream branch rather than merging the two histories.
- What is the data hygiene rule regarding large binary datasets in Git?Never commit or push them to Git repositories; keep them in shared storage or exclude them via .gitignore.
- How can you prevent large dataset files from being tracked by Git?Add them to .gitignore or keep them in shared storage outside the repository.
- Why is committing large binary datasets to Git problematic?They bloat the repository and should instead live in shared storage or be ignored via .gitignore.
- What history structure results from using git pull --rebase?A clean, linear history with no merge commits.
- What file is used to define a reproducible conda environment?An environment.yml file, which specifies the channels and pinned dependencies for the environment.
- Which channel should be listed in environment.yml to use conda-forge packages?channels: [conda-forge]
- How are dependencies specified in an environment.yml file?Under dependencies: as a list, with versions optionally pinned (e.g., python=3.12, numpy>=1.19).
- What does pinning a dependency version like python=3.12 accomplish?It locks that package to a specific version, helping ensure the environment is reproducible across machines.
- Why should you export only explicitly requested packages rather than all installed packages?To omit OS-specific transitive build hashes, keeping the environment file portable and reproducible across platforms.
- What problem do OS-specific transitive build hashes cause when exporting environments?They make the exported environment file platform-dependent and non-portable, so they should be excluded.
- What is the benefit of defining environments in an environment.yml file?It makes environments reproducible, so the same package set can be recreated consistently on other systems.
- What is the purpose of the channels key in environment.yml?It specifies which package repositories conda should search, such as conda-forge.
- What does the == operator test in Python?It tests whether two objects have equal values.
- What does the is operator test in Python?It tests whether two variables point to the exact same memory address (i.e., id(a) == id(b)).
- If a = [1,2,3] and b = [1,2,3], what are the results of a == b and a is b?a == b is True (equal values), but a is b is False (different objects in memory).
- What happens to a when you do b = a; b.append(4)?a is also mutated, because b is an alias pointing to the same list object.
- How do you make an independent copy of a list a?Use b = a.copy() so mutations to b do not affect a.
- Why are sentinel fill values like -99 or -9999.0 dangerous in observational datasets?If not replaced with np.nan before computing statistics, they severely bias results (e.g., pull means downward).
- Why does x == np.nan fail to detect missing values?Because x == np.nan is always False; use np.isnan(x) or np.isfinite(x) instead.
- Which NumPy functions detect NaN values?np.isnan(x) and np.isfinite(x).
- Which NumPy functions perform NaN-safe aggregations?np.nanmean() and np.nanstd() (and similar np.nan* functions).
- What is the difference between value equality and object identity?Value equality (==) compares contents/values; object identity (is) compares whether both references point to the same memory address.
- Why are NumPy vectorized operations like np.dot or @ faster than Python for loops?They call pre-compiled C/Fortran BLAS routines, making them roughly 10x-100x faster than pure Python for loops.
- In a 2D array with shape (rows, cols), what does axis=0 mean?axis=0 collapses across rows, operating down each column (e.g., a depth-averaged profile at each latitude).
- In a 2D array with shape (rows, cols), what does axis=1 mean?axis=1 collapses across columns, operating across each row (e.g., a meridional mean across latitudes at each depth).
- State the NumPy broadcasting rule for elementwise operations.Comparing trailing dimensions right-to-left, dimensions are compatible when they are equal or one of them is 1.
- How does broadcasting let you multiply temperature T of shape (2, 3) by a depth vector D of shape (2, 1)?D is broadcast across all 3 latitudes, so each depth value scales the row of temperatures at that depth.
- Given T of shape (2, 3) (depth, lat) and D of shape (2, 1), what does (T * D).mean(axis=1) produce?A 2-element array giving the meridional mean at each depth.
- What is the convention for plotting ocean pressure or depth on a profile plot?Plot depth/pressure on the y-axis with the axis inverted so values increase downward (ax.invert_yaxis() or ax.set_ylim(p_max, 0)).
- What is a T–S diagram used for in oceanography?A scatter plot of temperature vs. salinity used to identify water masses.
- Which NumPy functions perform fast matrix multiplication via BLAS?np.dot(a, b), np.matmul(A, B), and the @ operator.
- What does axis=0 produce when applied to a 2D (depth, lat) array?A depth-averaged profile at each latitude (collapsing across rows).
- What does axis=1 produce when applied to a 2D (depth, lat) array?A meridional mean across latitudes at each depth (collapsing across columns).
- What tool is mentioned for timing NumPy operations against Python loops?%timeit.
- When broadcasting two arrays, which dimensions are compared and in what order?Trailing dimensions are compared right-to-left.
- What happens when a compared dimension is 1 during broadcasting?That dimension is stretched to match the other array's size.
- What does the pandas expression df.where(df != -9999.0, np.nan) do?It replaces every occurrence of the sentinel value -9999.0 with NaN while preserving all valid entries.
- Why should you filter by quality flags and exclude NaNs before computing sample percentages?Because interpolated, missing, or NaN values would distort the percentages; only valid measurements should be counted.
- How do you count distinct geographic sampling stations in a DataFrame?Use df.drop_duplicates(subset=['latitude', 'longitude']).shape[0].
- How do you read a CSV with nested (hierarchical) column headers in pandas?Pass header=[0, 1] to pd.read_csv, which creates a MultiIndex for the columns.
- How can you aggregate across sub-levels of a MultiIndex table?Transpose the table or specify level=0 in .groupby().
- What is the difference between wide-form and long-form (tidy) data?Wide-form has values spread across columns (e.g., months JAN–DEC), while long-form has one observation per row (e.g., Year, Month, Anomaly).
- Which data form is required by seaborn relational and categorical plots like lineplot, boxplot, and jointplot?Long-form (tidy) data, where each row is a single observation.
- What is wide-form data well suited for in seaborn?Compact visualizations like heatmaps, e.g., sns.heatmap(df_wide.T).
- How do you convert wide-form data to long-form with pandas?Use pd.melt(df.reset_index(), id_vars=['YEAR'], var_name='Month', value_name='Anomaly').
- What does the usecols argument do in pd.read_csv?It selectively loads only the specified columns from the file.
- What does the index_col argument do in pd.read_csv?It sets the specified column as the DataFrame's index.
- What does the id_vars parameter do in pd.melt?It specifies the columns to keep as identifier variables (not unpivoted) during reshaping.
- What do the var_name and value_name parameters do in pd.melt?var_name names the column holding the former wide column labels, and value_name names the column holding the values.
- Why is df.reset_index() often called before pd.melt?Because melt cannot use the index as an identifier variable, so the index must be turned into a column first.
- What are the Lorenz equations?A simplified model of atmospheric convection rolls: ẋ = σ(y − x), ẏ = r x − y − x z, ż = x y − b z, with Prandtl number σ, Rayleigh number r, and geometric factor b.
- What parameter values produce the classic chaotic butterfly attractor in the Lorenz system?σ = 10, r = 28, b = 8/3.
- What do the Lorenz parameters σ, r, and b represent?σ is the Prandtl number, r is the Rayleigh number, and b is a geometric factor.
- Which numerical method is used to integrate the Lorenz equations in the section?Runge–Kutta 4/5 via scipy.integrate.solve_ivp.
- Why must unevenly spaced paleoclimate time series be interpolated before filtering or FFT analysis?Digital filters and FFTs strictly require uniform sample spacing Δt, but ice-core gas ages are unevenly spaced due to ice compaction.
- What is the Nyquist frequency formula for a uniform grid with spacing Δt?f_Nyq = 1 / (2 Δt).
- How do you apply a Butterworth low-pass filter to retain periods longer than 25 kyr?Normalize the cutoff frequency f_c = 1/25 kyr⁻¹ by the Nyquist frequency, then apply zero-phase filtering with scipy.signal.filtfilt(b, a, y_interp).
- Why should a time series be linearly detrended before taking an FFT?To prevent secular trends and zero-frequency leakage from swamping the spectral peaks.
- How are frequencies and positive-frequency power computed after an FFT?Use freqs = scipy.fft.fftfreq(N, d=dt) and take |fft(y)[:N//2]| for positive-frequency power/amplitude.
- What does xr.open_dataset() do?Loads a single NetCDF file into an xarray Dataset object.
- What does xr.open_mfdataset() do?Loads multiple NetCDF files matching a glob pattern into a single combined Dataset.
- What is the purpose of the combine='by_coords' argument in open_mfdataset?It combines multiple files by aligning them along their coordinate values.
- How do you materialize a lazily loaded Dask-backed xarray Dataset into memory?Call .load() or .compute() on the Dataset.
- What is the difference between .sel() and .isel() in xarray?.sel() selects by coordinate value (e.g., depth=0), while .isel() selects by integer position (e.g., time=0).
- How would you select depth 0 and latitudes between -30 and 30 using coordinate-aware indexing?ds.sel(depth=0, lat=slice(-30, 30))
- Why is crossing the dateline or prime meridian a problem for zonal means?Longitudes may not be contiguous (e.g., 120°E to 70°W), so averaging over longitude without reordering gives incorrect results.
- How can you make longitudes contiguous across the dateline before taking a zonal mean?Use ds.roll(lon=..., roll_coords=True) or xr.concat() to reorder longitudes so they span contiguously.
- How do you compute a climatological anomaly for a variable like PRECTOT?Subtract the time mean: anom = ds['PRECTOT'] - ds['PRECTOT'].mean(dim='time').
- What does roll_coords=True do in ds.roll()?It rolls the coordinate values along with the data so coordinates stay aligned with the rolled data.
- Why do high-latitude grid cells have smaller physical area than equatorial cells on a regular latitude–longitude grid?Meridians converge toward the poles, so the east-west spacing between longitudes shrinks with latitude, reducing each cell's physical area.
- What is the formula for the east-west grid spacing Δx(φ) on a regular latitude–longitude grid?Δx(φ) = R_E cos(φ) Δλ, where φ and λ are in radians.
- What is the formula for the north-south grid spacing Δy?Δy = R_E Δφ, with Δφ in radians.
- What is the physical area of a grid cell at latitude φ and longitude λ?Area(φ, λ) = R_E² cos(φ) Δφ Δλ, with angles in radians.
- What units must latitude and longitude be in when computing cos(φ) and cell areas?Radians; convert degrees with np.deg2rad(lat).
- How do you compute an area-weighted global mean in xarray?Multiply the field by cos(φ) (or by cell area) as weights and take the weighted mean, e.g. using .weighted(weights).mean().
- Why is a simple arithmetic mean of grid-cell values biased on a latitude–longitude grid?Cells at high latitudes represent less physical area, so an unweighted mean over-represents polar regions relative to their true area.
- What weighting factor is commonly used for global means on a regular lat–lon grid?cos(φ), the cosine of latitude, which is proportional to cell area (the Δφ Δλ and R_E² factors cancel in a weighted mean).
- How do you convert precipitation flux to a total mass rate per grid cell?Multiply the flux at each cell by that cell's physical area in m², giving kg s⁻¹.
- What is the unit of the total mass rate obtained after multiplying flux by cell area?kg s⁻¹.
- What is the physical meaning of multiplying a flux by grid-cell area?It integrates the flux over the cell, converting a per-area rate into a total rate for that cell.
- How would you compute the global total precipitation mass rate from gridded flux?Multiply each cell's flux by its area R_E² cos(φ) Δφ Δλ and sum over all cells.
- What happens to the cos(φ) weighting factor when computing a weighted global mean rather than a total?It cancels with the constant Δφ Δλ and R_E² factors, so cos(φ) alone can serve as the weight.
- In the area formula, what do Δφ and Δλ represent?The grid spacing in latitude and longitude, respectively, expressed in radians.
- In Cartopy, what does the projection argument in subplot_kw={'projection': ...} control?It sets the target map projection of the axes (how the map is drawn).
- In Cartopy, what does the transform argument inside a plotting call like ax.contourf(...) specify?It tells Cartopy which coordinate system the input data arrays are defined in.
- What is the difference between projection and transform in Cartopy plotting?projection sets the target map projection of the axes, while transform declares the coordinate system of the input data arrays.
- How do you fix the white seam at the dateline when contour-plotting global data in Cartopy?Use data_cyc, lon_cyc = cartopy.util.add_cyclic_point(data, coord=lon) before calling contourf.
- What does cartopy.util.add_cyclic_point do?It adds a cyclic point to the data (and longitude coordinate) so plots wrap seamlessly across the dateline, removing the white seam.
- Which type of colormap should be used for magnitude data such as cmocean's thermal, haline, or viridis?Sequential perceptually uniform colormaps.
- Which type of colormap should be used for anomalies, and why?Diverging colormaps centered at zero (e.g., cmo.balance, cmo.curl, RdBu_r), because they emphasize deviation in two directions from a midpoint.
- What is a perceptually uniform colormap?A colormap where equal steps in data values produce roughly equal perceived changes in color, avoiding misleading visual artifacts.
- Why prefer perceptually uniform colormaps over non-uniform ones like jet?They represent data magnitudes faithfully and avoid false boundaries or misleading emphasis created by uneven perceptual steps.
- In ccrs.Mollweide(central_longitude=-160), what does central_longitude control?It sets the longitude placed at the center of the Mollweide projection.
- When plotting with Cartopy, what coordinate system does ccrs.PlateCarree() represent?A simple longitude/latitude (equirectangular) coordinate system commonly used for input data arrays.
- What must you specify when your data arrays are in lon/lat but the axes use a different projection?Pass transform=ccrs.PlateCarree() (or the appropriate CRS) to the plotting call so Cartopy reprojects the data correctly.
Velocer मुफ़्त है: स्पेस्ड रिपिटिशन और किसी भी दस्तावेज़ से अपने खुद के कार्ड।
PDF to flashcards · Lecture to flashcards · Practice exam · Syllabus study plan · Anki import
University of Wisconsin–Madison के और डेक
- comp sci 240 midterm 1
- comp sci 240 midterm 2
- COMP SCI 240 Midterm 3
- COMP SCI 240 Final
- comp sci 300 full course review
- Math 234 - every chapter (multivariable calc)
- PSYCH 202 Exam 1 Review
- PSYCH 202 Exam 2 Review
- PSYCH 202 Exam 3 Review
- STAT 441: Advanced Sports Analytics · UW-Madison
- ECE 752: Advanced Computer Architecture I · UW-Madison
- CS 639: Introduction to Reinforcement Learning · UW-Madison