From 4e3758f8f303d74dae8333a3954ed14b9354aeba Mon Sep 17 00:00:00 2001 From: Roberto Susino Date: Mon, 9 Aug 2021 09:27:33 +0200 Subject: [PATCH] Code optimizations --- get_light_time.pro | 2 +- metis_dark_uvda.pro | 2 +- metis_dark_vlda.pro | 6 ++-- metis_rectify.pro | 1 + solo_get_carrot.pro | 6 ++-- solo_get_coords.pro | 4 +-- solo_get_solar_angles.pro | 76 +++++++++++++++++++-------------------- 7 files changed, 49 insertions(+), 48 deletions(-) diff --git a/get_light_time.pro b/get_light_time.pro index 04a9092..4146dcf 100644 --- a/get_light_time.pro +++ b/get_light_time.pro @@ -10,7 +10,7 @@ function get_light_time, utc, body, target, radvel = radvel ; radial component of the velocity - radvel = 1000.d0 * total(state[0 : 2] * state[3 : 5]) / sqrt(total(state[0 : 2]^2)) + radvel = 1000.d0 * total(state[0 : 2] * state[3 : 5])/sqrt(total(state[0 : 2]^2)) return, ltime end diff --git a/metis_dark_uvda.pro b/metis_dark_uvda.pro index a07f9bb..336fa32 100644 --- a/metis_dark_uvda.pro +++ b/metis_dark_uvda.pro @@ -2,7 +2,7 @@ function metis_dark_uvda, data, header, cal_pack, history = history dark = cal_pack.uv_channel.dark - dit = header.dit/1000.d0 + dit = header.dit/1000.D0 ndit1 = header.ndit1 ndit2 = header.ndit2 nbin = sqrt(header.nbin) diff --git a/metis_dark_vlda.pro b/metis_dark_vlda.pro index 8b66d65..23eeafb 100644 --- a/metis_dark_vlda.pro +++ b/metis_dark_vlda.pro @@ -4,14 +4,14 @@ function metis_dark_vlda, data, header, cal_pack, history = history dark = cal_pack.vl_channel.dark bias_dark = cal_pack.vl_channel.bias_dark - dit = header.dit + dit = header.dit/1000.D0 ndit = header.ndit nbin = sqrt(header.nbin) tsensor = header.tsensor - obt_beg = header.obt_beg/1000d0 + obt_beg = header.obt_beg/1000.D0 for i = 0, n_elements(bias_dark) - 1 do begin - if bias_dark[i].dit eq dit/1000. and bias_dark[i].nbin eq nbin and abs(bias_dark[i].tsensor - tsensor) lt 5 then begin + if bias_dark[i].dit eq dit and bias_dark[i].nbin eq nbin and abs(bias_dark[i].tsensor - tsensor) lt 5 then begin dark_image = float(readfits(cal_pack.path + bias_dark[i].file_name, /silent)) dark_file = bias_dark[i].file_name diff --git a/metis_rectify.pro b/metis_rectify.pro index f4829e5..327b060 100644 --- a/metis_rectify.pro +++ b/metis_rectify.pro @@ -4,5 +4,6 @@ function metis_rectify, image, filter image = reverse(image, 1) image = rotate(image, 1) endif + return, image end diff --git a/solo_get_carrot.pro b/solo_get_carrot.pro index b45b07e..8612729 100644 --- a/solo_get_carrot.pro +++ b/solo_get_carrot.pro @@ -4,7 +4,7 @@ function solo_get_carrot, utc jul_day = date_conv(utc, 'julian') - carr = (jul_day - 2398167.d0) / 27.2753d0 + 1 + carr = (jul_day - 2398167.D0)/27.2753D0 + 1 ; convert the requested date into ephemeris time @@ -21,7 +21,7 @@ function solo_get_carrot, utc ; calculate the fractional part of the decimal rotation number if he_lon lt 0. then he_lon = he_lon + 2. * !dpi - frac = 1.d0 - he_lon / (2. * !dpi) + frac = 1.D0 - he_lon/(2. * !dpi) n_carr = round(carr - frac) carr = n_carr + frac @@ -33,7 +33,7 @@ function solo_get_carrot, utc cspice_reclat, state[0 : 2], so_dist, so_lon, so_lat - carr = carr - so_lon / (2. * !dpi) + carr = carr - so_lon/(2. * !dpi) return, carr end diff --git a/solo_get_coords.pro b/solo_get_coords.pro index 18a1822..b8d2ec4 100644 --- a/solo_get_coords.pro +++ b/solo_get_coords.pro @@ -31,8 +31,8 @@ function solo_get_coords, utc, frame, obs, velocity = velocity, spherical = sphe cspice_reclat, coord, solo_dist, solo_lon, solo_lat if frame eq 'IAU_SUN' then solo_lon = (solo_lon + 2. * !dpi) mod (2. * !dpi) if keyword_set(degrees) then begin - solo_lat = solo_lat * 180.d0 / !dpi - solo_lon = solo_lon * 180.d0 / !dpi + solo_lat = solo_lat * 180.D0/!dpi + solo_lon = solo_lon * 180.D0/!dpi endif coord = [solo_dist, solo_lon, solo_lat] endif diff --git a/solo_get_solar_angles.pro b/solo_get_solar_angles.pro index 8a90b5f..5ff8e0f 100644 --- a/solo_get_solar_angles.pro +++ b/solo_get_solar_angles.pro @@ -1,61 +1,61 @@ function solo_get_solar_angles, utc - ; convert the requested date into ephemeris time + ; convert the requested date into ephemeris time - cspice_utc2et, utc, et + cspice_utc2et, utc, et - cspice_pxform, 'IAU_SUN', 'J2000', et, rot - sun_north = rot[2, *] + cspice_pxform, 'IAU_SUN', 'J2000', et, rot + sun_north = rot[2, *] - cspice_spkezr, 'SUN', et, 'J2000', 'NONE', 'SOLO', state, ltime - coord = state[0 : 2] - rad = coord / sqrt(total(coord^2, 1)) + cspice_spkezr, 'SUN', et, 'J2000', 'NONE', 'SOLO', state, ltime + coord = state[0 : 2] + rad = coord/sqrt(total(coord^2, 1)) - cel_north = [0., 0., 1.d0] + cel_north = [0., 0., 1.D0] - sun_proj = sun_north - total(rad * sun_north) * rad - sun_proj = sun_proj / sqrt(total(sun_proj^2)) + sun_proj = sun_north - total(rad * sun_north) * rad + sun_proj = sun_proj/sqrt(total(sun_proj^2)) - cel_proj = cel_north - total(rad * cel_north) * rad - cel_proj = cel_proj / sqrt(total(cel_proj^2)) + cel_proj = cel_north - total(rad * cel_north) * rad + cel_proj = cel_proj/sqrt(total(cel_proj^2)) - vec_proj = crossp(cel_north, rad) - vec_proj = vec_proj / sqrt(total(vec_proj^2)) + vec_proj = crossp(cel_north, rad) + vec_proj = vec_proj/sqrt(total(vec_proj^2)) - x_proj = total(sun_proj * cel_proj) - y_proj = total(sun_proj * vec_proj) + x_proj = total(sun_proj * cel_proj) + y_proj = total(sun_proj * vec_proj) - p0 = atan(y_proj, x_proj) * 180.d0 / !dpi + p0 = atan(y_proj, x_proj) * 180.D0/!dpi - cspice_pxform, 'IAU_SUN', 'ECLIPJ2000', et, rot - sun_north = rot[2, *] + cspice_pxform, 'IAU_SUN', 'ECLIPJ2000', et, rot + sun_north = rot[2, *] - cspice_spkezr, 'SUN', et, 'ECLIPJ2000', 'NONE', 'SOLO', state, ltime - coord = state[0 : 2] - rad = coord / sqrt(total(coord^2, 1)) + cspice_spkezr, 'SUN', et, 'ECLIPJ2000', 'NONE', 'SOLO', state, ltime + coord = state[0 : 2] + rad = coord/sqrt(total(coord^2, 1)) - eclip_north = cel_north + eclip_north = cel_north - sun_proj = sun_north - total(rad * sun_north) * rad - sun_proj = sun_proj / sqrt(total(sun_proj^2)) - - ecl_proj = eclip_north - total(rad * eclip_north) * rad - ecl_proj = ecl_proj / sqrt(total(ecl_proj^2)) + sun_proj = sun_north - total(rad * sun_north) * rad + sun_proj = sun_proj/sqrt(total(sun_proj^2)) - vec_proj = crossp(eclip_north, rad) - vec_proj = vec_proj / sqrt(total(vec_proj^2)) + ecl_proj = eclip_north - total(rad * eclip_north) * rad + ecl_proj = ecl_proj/sqrt(total(ecl_proj^2)) - x_proj = total(sun_proj * ecl_proj) - y_proj = total(sun_proj * vec_proj) + vec_proj = crossp(eclip_north, rad) + vec_proj = vec_proj/sqrt(total(vec_proj^2)) - ep = atan(y_proj, x_proj) * 180.d0 / !dpi + x_proj = total(sun_proj * ecl_proj) + y_proj = total(sun_proj * vec_proj) - cspice_spkezr, 'SUN', et, 'IAU_SUN', 'NONE', 'SOLO', state, ltime - coord = state[0 : 2] + ep = atan(y_proj, x_proj) * 180.D0/!dpi - cspice_reclat, coord, dist, lon, lat + cspice_spkezr, 'SUN', et, 'IAU_SUN', 'NONE', 'SOLO', state, ltime + coord = state[0 : 2] - b0 = -lat * 180.d0 / !dpi + cspice_reclat, coord, dist, lon, lat - return, [b0, p0, ep] + b0 = -lat * 180.D0/!dpi + + return, [b0, p0, ep] end -- GitLab