Home| superdarn |src.lib|tk|rpos| RPosCubic Index

RPosCubic

Syntax
void RPosCubic(int center,int bcrd,int rcrd,struct RadarSite *pos, int frang,int rsep,int rxrise,double height, double *x,double *y,double *z);
Header
superdarn/rpos.h
Library
rpos
Description

The RPosCubic function finds the position of a radar range-beam cell in cubic coordinates.

The function returns either the coordinates of the corner of the cell or the center point. If the argument center is set to zero then the corner point is returned, if center is set to (1) then the center point is returned.

The arguments bcrd and rcrd give the beam and range number of the cell. When calculating the corner point of a cell, the beam number ranges from zero to (16) and the range number ranges from zero to one more than the maximum range. This allows all the corners of the radar range-beam cells to be determined.

The argument pos points to a structure containing the radar site and hardware information.

The distance to the first range and the range separation are given by the arguments frang, rsep.

The argument rxrise gives the receiver rise time, if this is set to zero then the receiver rise time will be taken from the hardware table.

If the argument height is less than or equal to 90 it corresponds to the elevation angle in degrees associated with the calculation, otherwise is corresponds to the height in kilometers.

The calculated position in cartesian coordinates is stored at the locations pointed to by the arguments x, y, and z.

Returns
None
Errors
None
Example

Source Code: RPosCubic.c

/* RPosCubic.c
   ===========
   Author: R.J.Barnes

Copyright (c) 2012 The Johns Hopkins University/Applied Physics Laboratory

This file is part of the Radar Software Toolkit (RST).

RST is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

Modifications:


*/


#include <stdio.h>
#include <stdlib.h>

#include "rtypes.h"
#include "radar.h"
#include "rpos.h"

struct RadarNetwork *network; 
struct RadarSite *site; 

int main(int argc,char *argv[]) {
  char *envstr;
  FILE *fp;
  char *code=NULL;
  int st;
  int bm,rng;
  int frang=180,rsep=45,rxrise=100.0;
  double hgt=150.0;
  double x,y,z;

  envstr=getenv("SD_RADAR");
  if (envstr==NULL) {
    fprintf(stderr,"Environment variable 'SD_RADAR' must be defined.'n");
    exit(-1);
  }

  fp=fopen(envstr,"r");

  if (fp==NULL) {
    fprintf(stderr,"Could not locate radar information file.'n");
    exit(-1);
  }

  network=RadarLoad(fp);
  fclose(fp); 
  if (network==NULL) {
    fprintf(stderr,"Failed to read radar information.'n");
    exit(-1);
  }

  envstr=getenv("SD_HDWPATH");
  if (envstr==NULL) {
    fprintf(stderr,"Environment variable 'SD_HDWPATH' must be defined.'n");
    exit(-1);
  }

  RadarLoadHardware(envstr,network);
  
  code=argv[1];
  bm=atoi(argv[2]);
  rng=atoi(argv[3]);

  st=RadarGetID(network,code);

  site=RadarYMDHMSGetSite(RadarGetRadar(network,st),2002,8,30,10,30,0);

  RPosCubic(1,bm,rng,site,frang,rsep,rxrise,hgt,&x,&y,&z);

  fprintf(stdout,"RPosCubic'n");
  fprintf(stdout,"%s bm=%d rng=%d'n",code,bm,rng);
  fprintf(stdout,"x=%g y=%g z=%g'n",x,y,z);



  return 0;
}