Friday, May 30, 2014

svn tag

Reference goes here: http://svnbook.red-bean.com/en/1.6/svn.branchmerge.tags.html

Creating a Simple Tag

Once again, svn copy comes to the rescue. If you want to create a snapshot of /calc/trunk exactly as it looks in the HEAD
revision, make a copy of it:

$ svn copy http://svn.example.com/repos/calc/trunk \
           http://svn.example.com/repos/calc/tags/release-1.0 \
      -m "Tagging the 1.0 release of the 'calc' project."


Committed revision 902.


Creating a Complex Tag


Sometimes you may want your “snapshot” to be more complicated than a single directory at a single revision.

$ ls
my-working-copy/

$ svn copy my-working-copy \
           http://svn.example.com/repos/calc/tags/mytag \
           -m "Tag my existing working copy state."

Committed revision 940.

Thursday, May 29, 2014

function/subroutine in f90 (100th blog)

program aaa
   implicit none

   ! declaration : var + function
   integer i
   integer f1_ex    !!!!  must declare external function
   integer f2_ex    !!!!

   print *, f1_in()
   print *, f2_in()
   print *, f1_ex()
   print *, f2_ex()

   contains
      !====================
      ! internal function
      !====================
      ! way 1
      function f1_in() result (res)
         integer res
         res = 100
         return      !!! Not return res
      end function

      ! way 2 : function name as return variable
      integer function f2_in()
         f2_in = 200
         return
       !!FUNCTION must be present on the end-function-stmt of an internal or module function
      end function   

     !====================
     ! internal subroutine
     !====================
      subroutine s1_in()
         print *, 'this is internal sub'
      end subroutine




end



!====================
! external function
!====================
! way 1
function f1_ex() result(res)
   integer res
   res = 222
   return
end            !!! No function needed for external function

! way 2 : function name as return variable

integer function f2_ex()
   f2_ex = 333
   return
end

!====================
external subroutine  
!====================
subroutine s1_ex()
   print *, 'this is external sub'
end

overload operator in f90

Fortran 90: Overloaded Operators

Let's start this section out with an example. Define the data type vector, which is a double precision array of length 3.
type vector
   real*8 :: v(3)
end type vector
Put this definition in matvec.p for reference below. Now we could make a function to add two vectors.
function vadd(v1,v2) result (v3)
   include "matvec.p"         !!!! similar to c/c++
   type (vector), intent(in) :: v1,v2
   type (vector),  :: v3
   v3%v = v1%v + v2%v ! Note the use of array operations
end function vadd
The following code will add two vectors
type (vector) a,b,c
a = vadd(b,c)
Now using operator overloading, we can call the vadd function by using "+".
interface operator (+)
   function vadd(v1,v2) result (v3)
      include "matvec.p"
      type (vector), intent(in) :: v1,v2
      type (vector),  :: v3
   end function vadd
end interface
Adding two vectors is now
type (vector) a,b,c
a = b + c
Let's define a function that takes two vectors and returns the dot product as a scalar.
function vdot(v1,v2) result (dot)
   include "matvec.p"
   type (vector), intent(in) :; v1,v2
   real*8 :: dot
   integer i
   dot = 0.0d0
   do i=1,3
      dot = dot + v1%v(i) * v2%v(i)
   enddo
Taking the dot product is then
type (vector) a,b
real*8 c
c = vdot(a,b)
Once again, operator overloading could be used to call this function with the "*" operator. Or if that may be confusing, we can define a new operator ".dot."
interface operator (*)   !   or (.dot.)
   function vdot(v1,v2) result (dot)
      include "matvec.p"
      type (vector), intent(in) :: v1,v2
      real*8 :: dot
   end function vdot
end function interface
Taking the dot product is now
type (vector) a,b
real*8 c
c = a*b  ! or c = a.dot.b
These examples could all be done more simply using the array intrinsics. But in cases where the array intrinsics are not sufficient, creating our own data types can be a powerfull tool.
Return to Fortran 90 index

Thursday, May 22, 2014

vis, ir and wv


Original info from here: http://cimss.ssec.wisc.edu/sage/remote_sensing/lesson2/activities.html
 
1.To the right is a visible image where the satellite radiometer collected reflected energy from the visible part of the electromagnetic spectrum, or 0.6 microns. You can change the appearance of the extracted section by changing the cloud thickness or the surface characteristics. Click on the image to the right to begin the activity.
image



















1) the thicker clouds are, the lower Tb is. 
2) the warmer surface( snow/ice, crops, forest, ocean -->  warmer ), the bigger Contrast between cloud and surface characristics


2. The image to the right is an infrared (IR) image (10.7 microns) from a radiometer sampling the IR section of the electromagnetic spectrum. This is typical of the images you see on the TV weather. You can change the appearance of the extracted section by changing the cloud altitude (and its associated ambient air temperature) or the surface temperature. Click on the image to the right to begin the activity.
image 















1) the higher cloud altitude, the lower Tb. 
2) the higher Ground temperature, the bigger Contrast between cloud and surface

3. This image is from the water vapor (near-infrared or 6.7 microns) section of the electromagnetic spectrum, where the atmosphere is largely opaque to radiation. For this reason, water vapor images supply information about the top of the atmosphere. Click on the image to the right to explore how cloud altitude and upper tropospheric humidity alter the appearance of water vapor
image imagery.


















1) the higher cloud altitude, the lower Tb, 
2) the lower "upper tropospheric relative humidity", the bigger Contrast between cloud and upper troposphere.

laws of radiation

There are three laws in radiations.

1. Stefan-Boltzmann Law (dxu: higher T, emit more energy)
The difference between terrestrial and solar radiation is best explained by the Stefan-Boltzmann Law which states that the amount of energy per square meter per second that is emitted by an object is related to the fourth power of its Kelvin temperature. Therefore, a warmer object emits significantly more radiation than a cooler object. For example, the Sun emits about 160,000 times as much energy as the Earth because it is about 20 times hotter.

Energy emitted  = F(T**4)


2. Wien's Law  ( dxu: higher T,  shorter wavelength of energy emitted )
Another law critical to understanding radiation and satellite technology states that the temperature of the emitting body affects the wavelength of the radiant energy emitted. German physicist Wilhelm Wien (pronounced “ween”) won the 1911 Nobel Prize in physics for this discovery. Wien’s Law is simple division:
Wavelength (µm) of maximum = ________2900___________
Object’s temperature in Kelvin
Wien’s Law can be summarized as, the hotter an object, the shorter the wavelength of maximum emission of radiation.

3.  Kirchhoff’s Law ( dxu:  eat what, poop what )
If an object absorbs electromagnetic energy of a certain wavelength, it will also emit energy at that wavelength. This is Kirchhoff’s Law, stated more directly as: A good absorber of radiation is also a good emitter of radiation at that same wavelength. It is important to remember that how much radiation an object emits depends on its temperature. Waves are characterized by two properties: wavelength, the distance between wave crests, and amplitude, half the height from the peak of the crest to the lowest point of the wave.
The amount of energy in the wave increases for smaller wavelengths.


Electromagnetic Radiation
The energy Earth receives from the sun is called electromagnetic radiation which travels through space in the form of a wave with both electric and magnetic characteristics. Although we are talking about light, most of the electromagnetic spectrum cannot be detected by the human eye. Even satellite detectors only capture a small portion of the entire electromagnetic spectrum.The full range of wave frequencies in solar radiation is called the electromagnetic spectrum, shorter wavelengths have more energy than longer wavelengths. Because the Sun is much hotter than the Earth, (surface temperature of 5,880 Kelvin, approximately 10,000 degrees Fahrenheit) it radiates short-wave energy. The Sun warms the Earth, and the Earth radiates energy in response. But because the Earth’s average surface temperature is only about 288 Kelvin (about 59 degrees Fahrenheit), the energy Earth radiates has a longer wavelength than solar radiation. Ultimately, electromagnetic radiation determines Earth’s climate, since the planet must shed as much energy as it absorbs.
Radiometers
Remote sensing instruments on satellites are called radiometers. They are designed to accurately measure electromagnetic energy radiating from the earth and atmosphere. And everything emits electromagnetic radiation. More specifically, all objects with a temperature above absolute zero emit radiation.
Radiometers measure radiation of different wavelengths in discrete intervals by using mirrors that scan a region and reflect digital data back to the satellite to be transmitted down to earth for processing. Satellite radiometers can “see” in a wide range of electromagnetic spectral intervals. These intervals are called channels or spectral bands. In this course we will focus on the three most common channels: visible light (0.6 microns), longwave infrared (10 to 12 microns), and a special channel near one of the infrared absorption bands of water (6.7 microns) that we call the “water vapor channel.”
The ART of electromagnetic radiation
As with all energy, radiation can change form, but it must be conserved. The art to remembering what happens when electromagnetic energy moves through the atmosphere is that it can either be absorbed, reflected, or transmitted when it interacts with other objects. Visible satellite images depend on the availability of reflected sunlight. Infrared satellite images (IR) result from radiometers that detect emitted electromagnetic energy so meteorologists rely on IR images to track storms overnight.
The Importance of Contrast
Collecting electromagnetic energy from an area usually results in an image that provides instant identification of a feature, however, if there isn't enough contrast between the feature and it's surrounding, scientists look at the same scene in multiple channels or apply enhancements to the image to create the contrast necessary to discern the feature they are trying to study.
Atmospheric Opacity
Radiation detected by satellites is comprised of both terrestrial and atmospheric sources, however, energy from the earth's surface must travel through the atmosphere before it reaches the satellite. Satellite sensors are designed to be particularly sensitive to those wavelengths of radiant energy that can be reflected or emitted back up through the atmosphere to space (dxu: so radiometers can catch those signals). By using the laws of radiation to calibrate radiometers and interpret details displayed on satellite images, scientists can measure the height, temperature, moisture content (and more) about nearly every feature of the earth’s atmosphere, hydrosphere, lithosphere, and biosphere.

utc

Coordinated Universal Time (UTC) is the local time at Greenwich-England, which is at 0° longitude. Satellite images and other weather observations are recorded in UTC so scientists can refer to a global time frame. You can convert UTC to local time zones in the U.S. by subtracting one hour for every 15 degrees longitude.

Resolution
The resolution of an image refers to the potential detail provided by the imagery. In remote sensing we refer to three types of resolution: spatial, spectral and temporal.
Spatial Resolution refers to the size of the smallest feature that can be detected by a satellite sensor or displayed in a satellite image. It is usually presented as a single value representing the length of one side of a square. For example, a spatial resolution of 250m means that one pixel represents an area 250 by 250 meters on the ground. 
 
Spectral Resolution refers to the ability of a satellite sensor to measure specific wavlengths of the electromagnetic spectrum. The finer the spectral resolution, the narrower the wavelength range for a particular channel or band.

Temporal resolution refers to the time between images. The capability for satellites to provide images of the same geographical area more frequently has increased dramatically since the dawn of the space age.

Thursday, May 8, 2014

f90 namelist

File "nameList_1.conf" : 

&nameList_1
    ! comments allow
    name1='11111111111'
    name2='22222222222'
    size=4     !! To define size of dynamic array in namelist block 2
/

&nameList_2
    ! initialize array in namelist
    strArr='asfd' 'fdsf' '23232' 'sfss'
/

test.f90
  character(len=10) :: name1
  character(len=10) :: name2
  integer :: size

  !! Use size from nameList_1 to allocate space for strArr
  !! This is to make code more robostic
  character(len=10) , dimension(:), allocatable ::strArr  

  NAMELIST /nameList_1/name2, name1, size    ! order of keywords is NOT important
  NAMELIST /nameList_2/strArr

  READ(*,NML=nameList_1)    ! read name list block 1 from command line via "<"
  print  *, name1
  print  *, name2
  print  *, size
  allocate(strArr(size))
  ! open(8,file="nameList_1.conf", status='OLD', recl=80, delim='APOSTROPHE')
  ! read(8,NML=nameList_2)    ! read name list from a file
  ! close(8)      !!! also can read namelist block 2 via file


  READ(*,NML=nameList_2)    ! read name list from a file
  print  *, strArr
  deallocate(strArr)

Run
$ .a.out    <   nameList_1.conf






Tuesday, May 6, 2014

script_functions.bash

all the functions defined :

applyRegress  , biasFigsGen  , biasFigsGen_parallel  , biasGen  ,
biasMonitor  , biasMonitorRecord  ,
checkBias  , checkGeophysical  , checkNEDT  , checkQC  , checkStatus  ,
chopp  , clean  , ConstructList  , ConstructListFM  , CreatNamList  ,
DataExistEst  , dataQualityMonitor  , dataQualityMonitorRecord  ,
determineExtAndAlanysExtFromArgument  , DetermineExtAndAlanysExtFromArgument  ,
determineFileExt  , determineNdayBackDateExt  , determineSpatialResol  ,
determineTodayDateExt  , determineYesterdExtAndAlanysExt  ,
DetermineYesterdExtAndAlanysExt  , DirExistEst  , DirGen  ,
displayVerif  , DoMake  , dynamicBackground  ,
ErrMessDue2UsageInDailyMode  , ErrMessDue2UsageInOrbitalMode  ,
ExtractRdrFileNamesfromOrbit1  , ExtractRdrFileNamesfromOrbit2  ,
ExtractRdrFileNamesfromOrbitMT  , ExtractRdrFileNamesfromOrbitNpp  ,
ExtractRdrFileNamesfromOrbitTrmm  ,
figsGen  , figsGen2  , figsGenHr  , figsGen_parallel  , fm  ,
fmsdr2edr  , fwd  ,
getDateFromFile  , gridClimate  , gridGen  , gridGen_parallel  , gridRain  ,
imgHr  , jday2caldate  , leapYearEst  ,
makeClean  , mergeEdr  , mergeNedt  , mirs2nc  , mirs2nc_parallel  , nwp  ,
op_msg  , prepNWP  , PurgeDir  , qcRadioGeo  , QualityCheckOfArgument  ,
rdr2tdr  , SanityChecksOrbitProcess  , SanityChecksOrbitProcess1  ,
SanityChecksOrbitProcess2  , selMidGranule4NPP  , tdr2sdr  ,
verifBias  , vipp  , wait1dvar  , WriteListOfOutputs  ,
WriteListOfOutputs_QC  , wtMonitor  , yyyymmdd2jjj  ,