Thursday, January 17, 2008

EATS 1011 Lecture 5


 

  • Co2 has less of an impact on global warming than waper vapour, but CO2 can be controlled, water vapour isn't something humans can control
  • The surface temperature would be exactly the same as the effective temperature if we had no atmosphere but 30% albedo
  • Teffective =
  • Greenhouse effect
    • Dilute solar radiation heats (mostly) surface
    • Surface heats and emits mid-IR radiation which is absorbed(mostly) by atmospheric gases and clouds
      • The gases such as water vapour(clouds), carbon dioxide are what cause the greenhouse effect because they absorb radiation from the sun
    • Atmosphere re-radiates
      • Up to space
      • Back down to earth
    • Surface is heated "twice" (solar + mid-IR)
      • Figure 212 on slide
    • Red skys are caused by Rayleigh scattering

      •  
        • Where lambda is the wavelength
    • Albedo
      • Refers to visible part of the light spectrum
      • Albedo depends on the surface the light is directed to
      • Fresh snow is most reflective, 75-95% light reflected
      • Earth is about 30% 'albedo'
        • Not sure how to use the word 'albedo'
      • 6% reflected from atmosphere
      • 20% reflected by clouds
      • 4% is reflected naturally by the earth's surface
      • 51% of solar energy heats the Earth's surface
      • Total energy budget

      • Most infrared is absorbed by the earth's atmosphere instead of being released into space
      • When the sun goes down at night we don't freeze because infra red energy from the atmosphere continues heating the earth while the sun is down
      • 70 units of solar coming in , 50 heating the surface, after all the processing we have 70 units of energy leaving in the mid infrared

Earth's Energy Budget

  • Top of atmosphere
    • 70 units of solar in balanced by 70 units of Mid-IR emitted
  • Surface
    • Heated twice
    • Solar 51 units and 96 mid-IR units
    • We are heated by mid-IR at night
  • Read slides for more details on the web

Seasons

  • What are the drivers of the seasons
    • In the tropics there are no seasons
    • Seasons are at mid latitudes
  • orbital parameters
    • ellipticity of orbits
      • Perihelion
        • 147 x 106 km, 4th january
      • Ephelion
        • 153 x 106 km, 4th July
      • 7% change in insolation
    • Insolation:
      • The suns energy averaged over 24 hours
    • Obliquity: tilt
      • Rotation axis – pole star
      • 23.5 degrees
      • Solstice
        • N pole sun 21st June, sun overhead at noon at tropic of Cancer(23.5N)
        • S pole sun 21st December, sun overhead at noon at the tropic of Capricorn (23.5S)
        • Regions of perpetual day and night
      • Equinox
        • Axis 90 to sun – earth line
        • Vernal 21st march
        • Autumnal 21st September
        • Effects the length of the day
  • So what causes the seasons
    • Ellipticity
      • 7% so little impact
        • Except over eons
    • Obliquity
      • Large effect at mid- and polar latitudes
    • Latitude
      • In the tropics changes driven by overhead sun
      • Wet and dry seasons
      • Twice a year
  • Length of day light for various latitudes


 

CSE 2011 Lecture 5


 

Testing and Debugging

  • Create a test plan application that will probe the program with input and compare its output to see if the program is outputting the desired output from the test
  • Verification
    • Does the software meet its specifications
  • Validation
    • Does the software meet its requirements
  • Identify test criteria
    • What are the goats for comparing the system against its spec
      • Reliability, completeness, robustness
    • Identify target components for testing
      • In an OO system the classes and class hierarchies
    • Generate test cases
      • Produce test cases that can identify faults in an implementation
    • Execute test cases against target components
    • Evaluation
      • If expected outputs are not produced, a bug report is issued
  • Black box testing
    • Testing based on input and output alone
      • Do not consider underlying implementation
    • Test cases are generated from the spec
      • Pre and post conditions
    • Specific kinds of black box testing
      • Random testing
        • Generate random inputs
        • Easy to generate cases
        • Good at detecting failures
        • Must be able to easily generate expected output
      • Partition testing
        • Cannot try all possibly inputs
          • Partition input into equivalence classes
          • Every value in a class should behave similarly
        • Test cases
          • Just before the boundary
          • Just after the boundary
          • On a boundary
          • One from the middle of an equivalence class
        • Loops
          • Zero times through the body
          • Once through the body many times through the body

Tuesday, January 15, 2008

CSE 2031 Lecture 3

  • Integer types:
    • char
    • short
    • int
    • long
  • Floating point types:
    • float
    • double
    • long double

Char

  • 1 byte long
  • char<= short<=int<=long
  • denote characters in single quotes
  • \0 is a null character
  • char *b = "TEST";
    • is a string writer (assumption)
  • EOF
    • Reads as -1
      • Which is an array of ones
  • getchar() reads a byte of unsigned chars and stores 4 bytes to represent them
    • the promotion to int is done as a signed char
    • This is because of things like EOF
  • A signed char
    • Fills the other bytes with the first bit of the signed char
    • If it is signed and starts with 0
      • It is non negative
    • If it starts with 1
      • It is a negative number
  • An unsigned
    • Does not fill the other 3 bytes with the first bit but with all 0's when promoted to an int

Declarations

  • when you declare a variable in C it is visible throughout the score of the brackets that it is withheld
  • if you want a variable to be visible throughout a program put it above the main
  • to make one variable local to a file use the word 'static'

String

  • an array of char
  • there is no 'String' in C

Arrays

  • to declare an array in C
    • use type name[size]
      • example: int number[10]
  • you can initialize an array w/o a specified size
    • char s[] = {'h','e','l','l','o','\0', 'q'}
    • printf("%s /n", s}
      • returns 'hello'
        • note there is no q, that is because null character was before it

printF

  • %d prints integers
  • %s prints char characters
    • Prints until it finds a null character
    • Null character is \0
  • %p prints the address

Console

  • Od –cb filename
    • Describes a file in bits

CSE 2011 Lecture 4

Inheritance

  • An object is a collection of data and methods to operate on that data
    • Method is a procedure, function, operation
  • For a motor
    • turnOn
    • turnOff
    • setSpeed
  • An Object is an instance of a Class
    • The class provides the template for the object
  • Template gives
    • Data
    • Methods
  • Class contains methods, objects contain the data
    • Typically pictured as an object pointing to the class
    • Because the object uses methods
    • Objects share methods

Container

  • A collection of data is stored in a container
    • The data can be of different sub-types
  • Containers can be organized in different ways
    • Sequence,
    • Tree's
    • Table

Sequence

  • A list of objects in order
    • Contains a head, front, tail and last
    • Sequence = <head. ^ tail = front ^ <last>

EATS 1011 Lecture 4

  • In the northern hemisphere high pressure system goes clockwise, low pressure systems go counter-clockwise
    • This is due to the 'Coriolis effect'
  • GEOS bright colours represent 'cold'



  • EÅ
    is the solar energy at 1 AU ("constant")
  • 1 AU = 1.5.108 km = 1.5.1011 m
  • EÅ
    = Lʘ/( 4.pRp2) = Lʘ/( 4.p1 AU)2)
  • = 1.38.103 W m-2
  • Lʘ
    = EÅ
    4.p(1 AU)2
  • E(Rp) = Lʘ/( 4.pRp2) = EÅ
    /(Rp/1 AU)2
  • = EÅ
    /Rp2
  • Rp measured in AU


  • 37% of energy from the solar spectrum is near infrared


  • Most energy from the sun is less than 1 micron


  • We can see light where the sun outputs the most energy


  • The sun emits mostly in the UC, visible and near infrared regions


  • Humans can only see the visible region


  • The earth emits almost all in the mid infra red region


  • Satellites measuring IR can pick up differences in temperatures (clouds, water, surface, etc)


  • The area under the solar-radiation curve is the total (all wavelengths) solar radiance reaching the earth's orbit


    • =1.38*103 W m-2

Planetary Effective temperatures

  • The sun is far enough away to consider its rays parallel to eachother
  • Some light scatters back into space
  • The difference between infra red and solar energy is solar energy only comes through during the day
    • Emitted light as opposed to scattered
  • Albedo
    • A =
  • Radius of planet, b
  • Atmosphere emits as Planck body, sT4 W/m2
  • Steady state energy balance
    • Heating = cooling
  • Absorption (area*flux) = emission(area*flux)





  • Total amount of energy intercepted = π b2
  • Teff = effective temperature
  • Earth, rp 1AU
  • Albedo = .3 ( i.e. 70% of energy absorbed)
    • Teff = 255 Kelvin, = -18 Celcius
  • But The mean temperature is about 15 Celcius
    • T = 33 celcius
  • What is the implication for this temperature difference?
    • Natural greenhouse effect
      • Main greenhouse gas in the atmosphere is water vapour
  • Earth radiates / cools in the mid – IR (Wien's Law) from about 5km
  • Obliquity
    • the tilt of the planet from the sun

  • Mercury – rotates slowly and has a very large d/n temperature difference because heat deposited locally cannot be rapidly transferred to other locations such as the night side
  • Venus – T of 700k is actually the surface temperature and is evidence of a large greenhouse effect
  • Earth - natural greenhouse effect of about 33C
  • Mars - small greenhouse effect
  • Jupiter - interior heating - gravitational contraction
  • saturn - same
  • uranus - no
  • neptune - same as J and S
  • Pluto - aerosols and methane lead to a greenhouse effect

Heating of the Earth by Radiation

  • Solar radiation incident on atmosphere
    • Dilute 6000 K radiation
    • Scatters off air, clouds (numbers later)
    • Absorbed by aerosols, clouds, gases
    • Overall visible fairly transparent
    • Surface absorbs most radiation
      • Albedo trees(15%, ocean 10%)
    • Mid-IR radiation emitted from Earth / atmosphere system
    • Also called terrestrial radiation / long wavelength
    • Mid-IR is quite absorptive
    • "windows" 8-9, 10-12 чm
    • Main absorbers
      • H2O, CO2, clouds
    • Seconday absorbers
      • CH4, N2O, CFCI3,CF2Cl2, O3
    • Absorption of radiation
      • For graph on absorption
        • 100 = total absorption
        • 0 = no absorption
      • O2 and O3 absorb very energetic radiation from the sun
      • At about 9.6 microns ozone is acting as a greenhouse gas
    • Nitrous oxide
      • No role in visible spectrum
      • At about 4 microns and 6 microns absorbs quite a lot of energy
    • Methane
      • Heats the atmosphere a little bit
      • Plays a major role at about 6 microns
    • Water vapour
      • Water vapour absorbs a long range
        • Short mid and long range
        • From 4 -8 microns it plays a major rold
        • Plays a major role in controlling earths temperature
    • Carbon dioxide
      • Heats the atmosphere because it absorbs infrared radiation
      • Major band at about 15 microns
  • Most visible radiation goes to the surface

Transmission of solar and IR radiation


Thursday, January 10, 2008

CSE 2031 Lecture 2

Course Information

15% on assignments

30 % on midterm

Rest on exam


 

Recap from day 1

  • -Wall
    • Shows any errors the compiler wouldn't typically catch
  • -o
    • Allows you to change the executable files filename
  • -c
    • Stops compilation after the object module is produced
  • -E
    • Stops the compilation after the preprocessor phase
    • Textual manipulation of the source code


 

#include <stdio.h>

int main(void)

{

    int n, m;

    int product = 1; /* will eventually hold n!*/

    scanf("%d, &n);

    m=n;

    while ( m > 0)

        product *= m--;

    printf("%d! = %d\n", n, product);

    return 0;

}


 

#include <stdio.h>


 

int factorial(int) /* must be declared here in case user inputs a non-int*/

int main(void)

{

int n;

scanf("%d", &n)

printf("%d! = %d\n", n, factorial(n));

return 0;

int factorial(int x)

{

    /* base case*/

if (x<2) return 1;

    /*recursive calls*/

return x*factorial(x-1);

}

/*returns 5! = 120*/

}

If you want to compile with two files linking eachother use

  • cc -0 printFactorial factorial.c printfactorial2.c
  • this will link the code used in printFactorial from factorial.c so that printFactorial will work
    • this is more explicit than java because there isn't an 'import' feature
    • instead the feature is found in the compiler
  • when you compile a program that uses multiple files you have to name all the files on the command line
  • utility 'make'
    • merges files together
    • looks for a 'makefile'
      • in a make file there are dependency lines or action lines
        • action lines MUST be tabbed over
      • dependency lines describe the files in use
      • action lines tell console what to do to generate the file described in the dependency file
    • when 'make' is typed in console it runs the commands found in makefile
    • read makefile on course website, when it is available
      • console: make clean
      • runs the clean command found in 'makefile'
      • all warning flags are put in 'makefile' such as –Wall
  • Compiler
    • –l makes the console look in the library for functions used that aren't in stdio.h
    • –lm looks in the m (math) library


 

#include <stdio.h>

#include <math.h>

int main(void)

{

    double x;

    

    printf("Enter value for x: ");

    scanf("%1f", &x);

    

    printf("x = %f sqrt(x) = %1f\n", x, sqrt(x));

    return 0;

}

s

Array as an Abstract Data Type

  • What is an array?
    • An indexed, homogeneous collection of variables
    • Indexed from n-1 where n is the size
    • Multi dimensional
      • 1 index per dimension
    • The upper bound must be greater than or equal to the lower bound
  • An integer
    • is four bytes long, in sequence
  • to put one thing in to memory is called 'mapping'
  • row order is where the rows are separated and the columns are adjacent
    • column order is the opposite
  • if you have an array going from [-5 ..+6, +1 … 10, 3…5] of chess pieces
    • you would have an array of
      • -5, …, +6 of
        • An array of 1 , … , 10 of
          • An array of 3, …, 5 of chess pieces
  • Index – lower bound , to find the memory location of an object in a one dimensional array
    • For multi dimensional the 2nd 3rd… n dimensions start at the end point of the first but find an index the same way as a 1 dimensional array
  • Array Descriptor
    • Dimension count
      • For each dimension it needs to lower bound and upper bound and total size
      • A prototype array descriptor
        •     
  • A0 is the hypothetical location in memory where the first lower bound is found in memory.