Sponsored Content
Top Forums Shell Programming and Scripting Mapping with series from master file and calculate count Post 302451559 by poweroflinux on Tuesday 7th of September 2010 08:08:01 AM
Old 09-07-2010
Question Mapping with series from master file and calculate count

Hi All,

My shell script is calculating the count of each shortcode series wise whose sample output is as follows:
Code:
--------------------------
56882
9124 1
9172 1
9173 4
8923 6
9175 1
9058 2
7398 2
--------------------------
58585
series count
9124 1
8858 17
9061 21
9125 21
9126 7
9171 106
9172 4
7899 4
9173 7
9175 14
9059 92
7871 94
7396 183
7398 386
9060 13
--------------------------
58888
series count
9124 12
8858 2
9061 44
9125 36
9062 139
9171 20
9126 17
9172 94
9173 84
7899 113
8923 76
9175 59
9058 101
7870 327
7871 36
9059 24
7396 19
9122 202
7398 55
9060 62
--------------------------
57575
series count
8858 6
9124 6
9061 5
9062 26
9125 11
9171 5
9126 43
9172 14
9173 43
7899 7
9058 25
7870 15
8923 46
9175 71
7871 6
9059 13
7396 28
9122 17
7398 37
9060 15
--------------------------
57677
series count
9175 5

Code for generating above output is as follows:
Code:
Ydate=`date -d'-1 days' +'%Y-%m-%d'`
shortcodes=( "56882" "58585" "58888" "57575" "57677" );
for shortcode in ${shortcodes[@]}
do
        echo "--------------------------";
        echo $shortcode;
        echo "series count";
        grep "ShortCode=tel:${shortcode}" /opt/bea/ocsg_4.1/logs/customlogs/App_OP.log.$Ydate | awk -F"|" '{ arr[substr($2,1,4)]++ } END { for( no in arr) { print no , arr[no] } }'
done

And i have one master file whose data is as follows:
Code:
9059 North
7398 South
9175 North
9122 South
9175 North
7871 South

Now I want to map each series count with its Region mention in the master file and calculate the count region wise like following:
Code:
--------------------------
57677
 
North 5
South 0
--------------------------
57575
North 178
South 200
--------------------------
58888
North 123
South 109

Please help me in modifying my scipt for getting the above output
Thanks in advance.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

calculate the average of time series data using AWK

Hi, I have two time series data (below) merged into a file. t1 and t2 are in unit of second I want to calculate the average of V1 every second and count how many times "1" in V2 is occur within a second Input File: t1 V1 t2 V2 10.000000... (5 Replies)
Discussion started by: nica
5 Replies

2. Programming

Mapping all file at once or by page

This might be a silly question but I was wondering if, in case of huge files (2-3GB), it is more efficient to map the whole file at once, or to map it page by page. The file has to be processed sequentially from the start to the end. Thanks. (12 Replies)
Discussion started by: emitrax
12 Replies

3. Shell Programming and Scripting

Parse file from remote server to calculate count of string existence in that file

Hi I need to parse the file of same name which exist on different servers and calculate the count of string existed in both files. Say a file abc.log exist on 2 servers. I want to search for string "test" on both files and calculate the total count of search string's existence. For... (6 Replies)
Discussion started by: poweroflinux
6 Replies

4. Shell Programming and Scripting

Grep string from logs of last 1 hour on files of 2 different servers and calculate count

Hi, I am trying to grep a particular string from the files of 2 different servers without copying and calculate the total count of its occurence on both files. File structure is same on both servers and for reference as follows: 27-Aug-2010... (4 Replies)
Discussion started by: poweroflinux
4 Replies

5. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

6. Shell Programming and Scripting

Creating unique mapping from multiple mapping

Hello, I do not know if this is the right title to use. I have a large dictionary database which has the following structure: where a b c d e are in English and p q r s t are in a target language., the two separated by the delimiter =. What I am looking for is a perl script which will take... (5 Replies)
Discussion started by: gimley
5 Replies

7. Shell Programming and Scripting

Search and replace with mapping from a mapper file in a target file

Hello, I have a special problem. I have a file in 8 bit and would like to convert the whole database to 16Bit unicode. The mapping file has the following structure: The mapper is provided as a zip file The target file to be converted contains data in English and 8 bit Urdu mapping, a... (4 Replies)
Discussion started by: gimley
4 Replies

8. UNIX Desktop Questions & Answers

How can I replicate master master and master master MySQL databse replication and HA?

I have an application desigend in PHP and MySQl running on apache web server that I is running on a Amazon EC2 server Centos. I want to implement the master-master and master slave replication and high availability disaster recovery on this application database. For this I have created two... (0 Replies)
Discussion started by: Palak Sharma
0 Replies

9. Shell Programming and Scripting

Replacing 12 columns of one file by second file based on mapping in third file

i have a real data prod file with 80+ fields containing 1k -2k records. i have to extract say 12 columns out of this which are sensitive fields along with one primary key say SEQ_ID (like DOB,account no, name, SEQ_ID, govtid etc) in a lookup file. i have to replace these sensitive fields in... (11 Replies)
Discussion started by: megh12
11 Replies
mapproj(n)							    Tcl Library 							mapproj(n)

__________________________________________________________________________________________________________________________________________________

NAME
mapproj - Map projection routines SYNOPSIS
package require Tcl ?8.4? package require math::interpolate ?1.0? package require math::special ?0.2.1? package require mapproj ?1.0? ::mapproj::toPlateCarree lambda_0 phi_0 lambda phi ::mapproj::fromPlateCarree lambda_0 phi_0 x y ::mapproj::toCylindricalEqualArea lambda_0 phi_0 lambda phi ::mapproj::fromCylindricalEqualArea lambda_0 phi_0 x y ::mapproj::toMercator lambda_0 phi_0 lambda phi ::mapproj::fromMercator lambda_0 phi_0 x y ::mapproj::toMillerCylindrical lambda_0 lambda phi ::mapproj::fromMillerCylindrical lambda_0 x y ::mapproj::toSinusoidal lambda_0 phi_0 lambda phi ::mapproj::fromSinusoidal lambda_0 phi_0 x y ::mapproj::toMollweide lambda_0 lambda phi ::mapproj::fromMollweide lambda_0 x y ::mapproj::toEckertIV lambda_0 lambda phi ::mapproj::fromEckertIV lambda_0 x y ::mapproj::toEckertVI lambda_0 lambda phi ::mapproj::fromEckertVI lambda_0 x y ::mapproj::toRobinson lambda_0 lambda phi ::mapproj::fromRobinson lambda_0 x y ::mapproj::toCassini lambda_0 phi_0 lambda phi ::mapproj::fromCassini lambda_0 phi_0 x y ::mapproj::toPeirceQuincuncial lambda_0 lambda phi ::mapproj::fromPeirceQuincuncial lambda_0 x y ::mapproj::toOrthographic lambda_0 phi_0 lambda phi ::mapproj::fromOrthographic lambda_0 phi_0 x y ::mapproj::toStereographic lambda_0 phi_0 lambda phi ::mapproj::fromStereographic lambda_0 phi_0 x y ::mapproj::toGnomonic lambda_0 phi_0 lambda phi ::mapproj::fromGnomonic lambda_0 phi_0 x y ::mapproj::toAzimuthalEquidistant lambda_0 phi_0 lambda phi ::mapproj::fromAzimuthalEquidistant lambda_0 phi_0 x y ::mapproj::toLambertAzimuthalEqualArea lambda_0 phi_0 lambda phi ::mapproj::fromLambertAzimuthalEqualArea lambda_0 phi_0 x y ::mapproj::toHammer lambda_0 lambda phi ::mapproj::fromHammer lambda_0 x y ::mapproj::toConicEquidistant lambda_0 phi_0 phi_1 phi_2 lambda phi ::mapproj::fromConicEquidistant lambda_0 phi_0 phi_1 phi_2 x y ::mapproj::toAlbersEqualAreaConic lambda_0 phi_0 phi_1 phi_2 lambda phi ::mapproj::fromAlbersEqualAreaConic lambda_0 phi_0 phi_1 phi_2 x y ::mapproj::toLambertConformalConic lambda_0 phi_0 phi_1 phi_2 lambda phi ::mapproj::fromLambertConformalConic lambda_0 phi_0 phi_1 phi_2 x y ::mapproj::toLambertCylindricalEqualArea lambda_0 phi_0 lambda phi ::mapproj::fromLambertCylindricalEqualArea lambda_0 phi_0 x y ::mapproj::toBehrmann lambda_0 phi_0 lambda phi ::mapproj::fromBehrmann lambda_0 phi_0 x y ::mapproj::toTrystanEdwards lambda_0 phi_0 lambda phi ::mapproj::fromTrystanEdwards lambda_0 phi_0 x y ::mapproj::toHoboDyer lambda_0 phi_0 lambda phi ::mapproj::fromHoboDyer lambda_0 phi_0 x y ::mapproj::toGallPeters lambda_0 phi_0 lambda phi ::mapproj::fromGallPeters lambda_0 phi_0 x y ::mapproj::toBalthasart lambda_0 phi_0 lambda phi ::mapproj::fromBalthasart lambda_0 phi_0 x y _________________________________________________________________ DESCRIPTION
The mapproj package provides a set of procedures for converting between world co-ordinates (latitude and longitude) and map co-ordinates on a number of different map projections. COMMANDS
The following commands convert between world co-ordinates and map co-ordinates: ::mapproj::toPlateCarree lambda_0 phi_0 lambda phi Converts to the plate carree (cylindrical equidistant) projection. ::mapproj::fromPlateCarree lambda_0 phi_0 x y Converts from the plate carree (cylindrical equidistant) projection. ::mapproj::toCylindricalEqualArea lambda_0 phi_0 lambda phi Converts to the cylindrical equal-area projection. ::mapproj::fromCylindricalEqualArea lambda_0 phi_0 x y Converts from the cylindrical equal-area projection. ::mapproj::toMercator lambda_0 phi_0 lambda phi Converts to the Mercator (cylindrical conformal) projection. ::mapproj::fromMercator lambda_0 phi_0 x y Converts from the Mercator (cylindrical conformal) projection. ::mapproj::toMillerCylindrical lambda_0 lambda phi Converts to the Miller Cylindrical projection. ::mapproj::fromMillerCylindrical lambda_0 x y Converts from the Miller Cylindrical projection. ::mapproj::toSinusoidal lambda_0 phi_0 lambda phi Converts to the sinusoidal (Sanson-Flamsteed) projection. projection. ::mapproj::fromSinusoidal lambda_0 phi_0 x y Converts from the sinusoidal (Sanson-Flamsteed) projection. projection. ::mapproj::toMollweide lambda_0 lambda phi Converts to the Mollweide projection. ::mapproj::fromMollweide lambda_0 x y Converts from the Mollweide projection. ::mapproj::toEckertIV lambda_0 lambda phi Converts to the Eckert IV projection. ::mapproj::fromEckertIV lambda_0 x y Converts from the Eckert IV projection. ::mapproj::toEckertVI lambda_0 lambda phi Converts to the Eckert VI projection. ::mapproj::fromEckertVI lambda_0 x y Converts from the Eckert VI projection. ::mapproj::toRobinson lambda_0 lambda phi Converts to the Robinson projection. ::mapproj::fromRobinson lambda_0 x y Converts from the Robinson projection. ::mapproj::toCassini lambda_0 phi_0 lambda phi Converts to the Cassini (transverse cylindrical equidistant) projection. ::mapproj::fromCassini lambda_0 phi_0 x y Converts from the Cassini (transverse cylindrical equidistant) projection. ::mapproj::toPeirceQuincuncial lambda_0 lambda phi Converts to the Peirce Quincuncial Projection. ::mapproj::fromPeirceQuincuncial lambda_0 x y Converts from the Peirce Quincuncial Projection. ::mapproj::toOrthographic lambda_0 phi_0 lambda phi Converts to the orthographic projection. ::mapproj::fromOrthographic lambda_0 phi_0 x y Converts from the orthographic projection. ::mapproj::toStereographic lambda_0 phi_0 lambda phi Converts to the stereographic (azimuthal conformal) projection. ::mapproj::fromStereographic lambda_0 phi_0 x y Converts from the stereographic (azimuthal conformal) projection. ::mapproj::toGnomonic lambda_0 phi_0 lambda phi Converts to the gnomonic projection. ::mapproj::fromGnomonic lambda_0 phi_0 x y Converts from the gnomonic projection. ::mapproj::toAzimuthalEquidistant lambda_0 phi_0 lambda phi Converts to the azimuthal equidistant projection. ::mapproj::fromAzimuthalEquidistant lambda_0 phi_0 x y Converts from the azimuthal equidistant projection. ::mapproj::toLambertAzimuthalEqualArea lambda_0 phi_0 lambda phi Converts to the Lambert azimuthal equal-area projection. ::mapproj::fromLambertAzimuthalEqualArea lambda_0 phi_0 x y Converts from the Lambert azimuthal equal-area projection. ::mapproj::toHammer lambda_0 lambda phi Converts to the Hammer projection. ::mapproj::fromHammer lambda_0 x y Converts from the Hammer projection. ::mapproj::toConicEquidistant lambda_0 phi_0 phi_1 phi_2 lambda phi Converts to the conic equidistant projection. ::mapproj::fromConicEquidistant lambda_0 phi_0 phi_1 phi_2 x y Converts from the conic equidistant projection. ::mapproj::toAlbersEqualAreaConic lambda_0 phi_0 phi_1 phi_2 lambda phi Converts to the Albers equal-area conic projection. ::mapproj::fromAlbersEqualAreaConic lambda_0 phi_0 phi_1 phi_2 x y Converts from the Albers equal-area conic projection. ::mapproj::toLambertConformalConic lambda_0 phi_0 phi_1 phi_2 lambda phi Converts to the Lambert conformal conic projection. ::mapproj::fromLambertConformalConic lambda_0 phi_0 phi_1 phi_2 x y Converts from the Lambert conformal conic projection. Among the cylindrical equal-area projections, there are a number of choices of standard parallels that have names: ::mapproj::toLambertCylindricalEqualArea lambda_0 phi_0 lambda phi Converts to the Lambert cylindrical equal area projection. (standard parallel is the Equator.) ::mapproj::fromLambertCylindricalEqualArea lambda_0 phi_0 x y Converts from the Lambert cylindrical equal area projection. (standard parallel is the Equator.) ::mapproj::toBehrmann lambda_0 phi_0 lambda phi Converts to the Behrmann cylindrical equal area projection. (standard parallels are 30 degrees North and South) ::mapproj::fromBehrmann lambda_0 phi_0 x y Converts from the Behrmann cylindrical equal area projection. (standard parallels are 30 degrees North and South.) ::mapproj::toTrystanEdwards lambda_0 phi_0 lambda phi Converts to the Trystan Edwards cylindrical equal area projection. (standard parallels are 37.4 degrees North and South) ::mapproj::fromTrystanEdwards lambda_0 phi_0 x y Converts from the Trystan Edwards cylindrical equal area projection. (standard parallels are 37.4 degrees North and South.) ::mapproj::toHoboDyer lambda_0 phi_0 lambda phi Converts to the Hobo-Dyer cylindrical equal area projection. (standard parallels are 37.5 degrees North and South) ::mapproj::fromHoboDyer lambda_0 phi_0 x y Converts from the Hobo-Dyer cylindrical equal area projection. (standard parallels are 37.5 degrees North and South.) ::mapproj::toGallPeters lambda_0 phi_0 lambda phi Converts to the Gall-Peters cylindrical equal area projection. (standard parallels are 45 degrees North and South) ::mapproj::fromGallPeters lambda_0 phi_0 x y Converts from the Gall-Peters cylindrical equal area projection. (standard parallels are 45 degrees North and South.) ::mapproj::toBalthasart lambda_0 phi_0 lambda phi Converts to the Balthasart cylindrical equal area projection. (standard parallels are 50 degrees North and South) ::mapproj::fromBalthasart lambda_0 phi_0 x y Converts from the Balthasart cylindrical equal area projection. (standard parallels are 50 degrees North and South.) ARGUMENTS
The following arguments are accepted by the projection commands: lambda Longitude of the point to be projected, in degrees. phi Latitude of the point to be projected, in degrees. lambda_0 Longitude of the center of the sheet, in degrees. For many projections, this figure is also the reference meridian of the projec- tion. phi_0 Latitude of the center of the sheet, in degrees. For the azimuthal projections, this figure is also the latitude of the center of the projection. phi_1 Latitude of the first reference parallel, for projections that use reference parallels. phi_2 Latitude of the second reference parallel, for projections that use reference parallels. x X co-ordinate of a point on the map, in units of Earth radii. y Y co-ordinate of a point on the map, in units of Earth radii. RESULTS
For all of the procedures whose names begin with 'to', the return value is a list comprising an x co-ordinate and a y co-ordinate. The co- ordinates are relative to the center of the map sheet to be drawn, measured in Earth radii at the reference location on the map. For all of the functions whose names begin with 'from', the return value is a list comprising the longitude and latitude, in degrees. CHOOSING A PROJECTION
This package offers a great many projections, because no single projection is appropriate to all maps. This section attempts to provide guidance on how to choose a projection. First, consider the type of data that you intend to display on the map. If the data are directional (e.g., winds, ocean currents, or mag- netic fields) then you need to use a projection that preserves angles; these are known as conformal projections. Conformal projections include the Mercator, the Albers azimuthal equal-area, the stereographic, and the Peirce Quincuncial projection. If the data are thematic, describing properties of land or water, such as temperature, population density, land use, or demographics; then you need a projection that will show these data with the areas on the map proportional to the areas in real life. These so-called equal area projections include the various cylindrical equal area projections, the sinusoidal projection, the Lambert azimuthal equal-area projection, the Albers equal-area conic projection, and several of the world-map projections (Miller Cylindrical, Mollweide, Eckert IV, Eckert VI, Robinson, and Hammer). If the significant factor in your data is distance from a central point or line (such as air routes), then you will do best with an equidis- tant projection such as plate carree, Cassini, azimuthal equidistant, or conic equidistant. If direction from a central point is a criti- cal factor in your data (for instance, air routes, radio antenna pointing), then you will almost surely want to use one of the azimuthal projections. Appropriate choices are azimuthal equidistant, azimuthal equal-area, stereographic, and perhaps orthographic. Next, consider how much of the Earth your map will cover, and the general shape of the area of interest. For maps of the entire Earth, the cylindrical equal area, Eckert IV and VI, Mollweide, Robinson, and Hammer projections are good overall choices. The Mercator projection is traditional, but the extreme distortions of area at high latitudes make it a poor choice unless a conformal projection is required. The Peirce projection is a better choice of conformal projection, having less distortion of landforms. The Miller Cylindrical is a compromise designed to give shapes similar to the traditional Mercator, but with less polar stretching. The Peirce Quincuncial projection shows all the continents with acceptable distortion if a reference meridian close to +20 degrees is chosen. The Robinson projection yields attrac- tive maps for things like political divisions, but should be avoided in presenting scientific data, since other projections have moe useful geometric properties. If the map will cover a hemisphere, then choose stereographic, azimuthal-equidistant, Hammer, or Mollweide projections; these all project the hemisphere into a circle. If the map will cover a large area (at least a few hundred km on a side), but less than a hemisphere, then you have several choices. Azimuthal projections are usually good (choose stereographic, azimuthal equidistant, or Lambert azimuthal equal-area according to whether shapes, distances from a central point, or areas are important). Azimuthal projections (and possibly the Cassini projection) are the only really good choices for mapping the polar regions. If the large area is in one of the temperate zones and is round or has a primarily east-west extent, then the conic projections are good choices. Choose the Lambert conformal conic, the conic equidistant, or the Albers equal-area conic according to whether shape, distance, or area are the most important parameters. For any of these, the reference parallels should be chosen at approximately 1/6 and 5/6 of the range of latitudes to be displayed. For instance, maps of the 48 coterminous United States are attractive with reference parallels of 28.5 and 45.5 degrees. If the large area is equatorial and is round or has a primarily east-west extent, then the Mercator projection is a good choice for a con- formal projection; Lambert cylindrical equal-area and sinusoidal projections are good equal-area projections; and the plate carree is a good equidistant projection. Large areas having a primarily North-South aspect, particularly those spanning the Equator, need some other choices. The Cassini projec- tion is a good choice for an equidistant projection (for instance, a Cassini projection with a central meridian of 80 degrees West produces an attractive map of the Americas). The cylindrical equal-area, Albers equal-area conic, sinusoidal, Mollweide and Hammer projections are possible choices for equal-area projections. A good conformal projection in this situation is the Transverse Mercator, which alas, is not yet implemented. Small areas begin to get into a realm where the ellipticity of the Earth affects the map scale. This package does not attempt to handle accurate mapping for large-scale topographic maps. If slight scale errors are acceptable in your application, then any of the projections appropriate to large areas should work for small ones as well. There are a few projections that are included for their special properties. The orthographic projection produces views of the Earth as seen from space. The gnomonic projection produces a map on which all great circles (the shortest distance between two points on the Earth's surface) are rendered as straight lines. While this projection is useful for navigational planning, it has extreme distortions of shape and area, and can display only a limited area of the Earth (substantially less than a hemisphere). COPYRIGHT
Copyright (c) 2007 Kevin B. Kenny <kennykb@acm.org> mapproj 0.1 mapproj(n)
All times are GMT -4. The time now is 06:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy