Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 35 additions & 16 deletions src/components/ui/aladin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ interface AdditionalSource {
ra: number;
dec: number;
label: string;
description?: string;
}

interface AladinViewerProps {
ra?: number;
dec?: number;
ra: number;
dec: number;
fov?: number;
survey?: string;
target?: string;
className?: string;
additionalSources?: AdditionalSource[];
}
Expand All @@ -22,7 +22,6 @@ export function AladinViewer({
dec,
fov = 0.5,
survey = "P/DSS2/color",
target,
className = "w-full h-96",
additionalSources,
}: AladinViewerProps) {
Expand All @@ -42,43 +41,55 @@ export function AladinViewer({
showCooGridControl: false,
});

if (target) {
aladin.gotoObject(target);
} else if (ra !== undefined && dec !== undefined) {
aladin.gotoRaDec(ra, dec);
}
aladin.gotoRaDec(ra, dec);

if (additionalSources && additionalSources.length > 0) {
const catalog = window.A.catalog({
const nameCatalog = window.A.catalog({
labelColumn: "name",
shape: "cross",
color: "black",
displayLabel: true,
labelColor: "#fff",
labelColor: "lightgrey",
labelFont: "14px sans-serif",
});
aladin.addCatalog(catalog);
const descrCatalog = window.A.catalog({
color: "black",
shape: "cross",
});
aladin.addCatalog(nameCatalog);
aladin.addCatalog(descrCatalog);

additionalSources.forEach((source) => {
catalog.addSources(
if (source.description) {
descrCatalog.addSources([
window.A.marker(source.ra, source.dec, {
name: source.label,
popupTitle: source.label,
popupDesc: source.description,
}),
]);
}
nameCatalog.addSources(
window.A.source(source.ra, source.dec, { name: source.label }),
);
});
}
} catch (error) {
console.error("Error initializing Aladin:", error);
}
}, [ra, dec, fov, survey, target, additionalSources]);
}, [ra, dec, fov, survey, additionalSources]);

return <div ref={aladinDivRef} className={classNames("border", className)} />;
}

interface AladinCatalog {
addSources: (sources: AladinSource) => void;
addSources: (sources: AladinSource | AladinSource[]) => void;
}

interface AladinSource {
ra: number;
dec: number;
properties?: { name?: string };
properties?: { name?: string; popupTitle?: string; popupDesc?: string };
}

declare global {
Expand All @@ -105,12 +116,20 @@ declare global {
displayLabel?: boolean;
labelColor?: string;
labelFont?: string;
sourceSize?: number;
shape?: string;
color?: string;
}) => AladinCatalog;
source: (
ra: number,
dec: number,
properties?: { name?: string },
) => AladinSource;
marker: (
ra: number,
dec: number,
properties?: { name?: string; popupTitle?: string; popupDesc?: string },
) => AladinSource;
};
}
}
241 changes: 119 additions & 122 deletions src/components/ui/catalog-data.tsx
Original file line number Diff line number Diff line change
@@ -1,139 +1,136 @@
import { ReactElement } from "react";
Copy link
Member Author

@Kraysent Kraysent Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кнопка Skip/Go Back/Go to table

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделаю отдельно

import { CommonTable } from "./common-table";
import { PgcObject, Schema } from "../../clients/backend/types.gen";
import { Catalogs, Schema } from "../../clients/backend/types.gen";

interface CatalogDataProps {
object: PgcObject;
schema: Schema | null;
catalogs: Catalogs;
schema: Schema;
}

function formatValueWithError(
value: number | undefined,
error: number | undefined,
unit?: string,
decimalPlaces: number = 0,
): string {
if (value === undefined) return "NULL";
const formattedValue = value.toFixed(decimalPlaces);
const formattedError =
error?.toFixed(decimalPlaces) || "0".padEnd(decimalPlaces + 1, "0");

if (!unit) {
return `${formattedValue} ± ${formattedError}`;
}

return `${formattedValue} ${unit} ± ${formattedError} ${unit}`;
}

export function CatalogData({
object,
catalogs,
schema,
}: CatalogDataProps): ReactElement {
if (!object || !schema) return <div />;

const coordinatesColumns = [
{ name: "Parameter" },
{ name: "Value" },
{ name: "Unit" },
{ name: "Error" },
{ name: "Error unit" },
];

const coordinatesData = [
{
Parameter: "Right ascension",
Value: object.catalogs?.coordinates?.equatorial?.ra?.toFixed(6) || "NULL",
Unit: schema.units.coordinates?.equatorial?.ra || "NULL",
Error:
object.catalogs?.coordinates?.equatorial?.e_ra?.toFixed(6) || "NULL",
"Error unit": schema.units.coordinates?.equatorial?.e_ra || "NULL",
},
{
Parameter: "Declination",
Value:
object.catalogs?.coordinates?.equatorial?.dec?.toFixed(6) || "NULL",
Unit: schema.units.coordinates?.equatorial?.dec || "NULL",
Error:
object.catalogs?.coordinates?.equatorial?.e_dec?.toFixed(6) || "NULL",
"Error unit": schema.units.coordinates?.equatorial?.e_dec || "NULL",
},
{
Parameter: "Galactic longitude",
Value: object.catalogs?.coordinates?.galactic?.lon?.toFixed(6) || "NULL",
Unit: schema.units.coordinates?.galactic?.lon || "NULL",
Error:
object.catalogs?.coordinates?.galactic?.e_lon?.toFixed(6) || "NULL",
"Error unit": schema.units.coordinates?.galactic?.e_lon || "NULL",
},
{
Parameter: "Galactic latitude",
Value: object.catalogs?.coordinates?.galactic?.lat?.toFixed(6) || "NULL",
Unit: schema.units.coordinates?.galactic?.lat || "NULL",
Error:
object.catalogs?.coordinates?.galactic?.e_lat?.toFixed(6) || "NULL",
"Error unit": schema.units.coordinates?.galactic?.e_lat || "NULL",
},
];
if (!catalogs) return <div />;

const redshiftColumns = [
{ name: "Parameter" },
{ name: "Value" },
{ name: "Error" },
];
const columns = [{ name: "Parameter" }, { name: "Value" }];

const redshiftData = [
{
Parameter: "z",
Value: object.catalogs?.redshift?.z?.toFixed(6) || "NULL",
Error: object.catalogs?.redshift?.e_z?.toFixed(6) || "NULL",
},
];
const data = [];

const velocityColumns = [
{ name: "Parameter" },
{ name: "Value" },
{ name: "Unit" },
{ name: "Error" },
{ name: "Error unit" },
];
if (catalogs?.designation?.name) {
data.push({
Parameter: "Name",
Value: catalogs.designation.name,
});
}

const velocityData = [
{
Parameter: "Heliocentric",
Value: object.catalogs?.velocity?.heliocentric?.v?.toFixed(2) || "NULL",
Unit: schema.units.velocity?.heliocentric?.v || "NULL",
Error: object.catalogs?.velocity?.heliocentric?.e_v?.toFixed(2) || "NULL",
"Error unit": schema.units.velocity?.heliocentric?.e_v || "NULL",
},
{
Parameter: "Local Group",
Value: object.catalogs?.velocity?.local_group?.v?.toFixed(2) || "NULL",
Unit: schema.units.velocity?.local_group?.v || "NULL",
Error: object.catalogs?.velocity?.local_group?.e_v?.toFixed(2) || "NULL",
"Error unit": schema.units.velocity?.local_group?.e_v || "NULL",
},
{
Parameter: "CMB (old)",
Value: object.catalogs?.velocity?.cmb_old?.v?.toFixed(2) || "NULL",
Unit: schema.units.velocity?.cmb_old?.v || "NULL",
Error: object.catalogs?.velocity?.cmb_old?.e_v?.toFixed(2) || "NULL",
"Error unit": schema.units.velocity?.cmb_old?.e_v || "NULL",
},
{
Parameter: "CMB",
Value: object.catalogs?.velocity?.cmb?.v?.toFixed(2) || "NULL",
Unit: schema.units.velocity?.cmb?.v || "NULL",
Error: object.catalogs?.velocity?.cmb?.e_v?.toFixed(2) || "NULL",
"Error unit": schema.units.velocity?.cmb?.e_v || "NULL",
},
];
if (catalogs?.coordinates) {
data.push(
{
Parameter: "Equatorial RA",
Value: formatValueWithError(
catalogs.coordinates.equatorial?.ra,
catalogs.coordinates.equatorial?.e_ra,
schema.units.coordinates?.equatorial?.ra,
2,
),
},
{
Parameter: "Equatorial Dec",
Value: formatValueWithError(
catalogs.coordinates.equatorial?.dec,
catalogs.coordinates.equatorial?.e_dec,
schema.units.coordinates?.equatorial?.dec,
2,
),
},
{
Parameter: "Galactic l",
Value: formatValueWithError(
catalogs.coordinates.galactic?.lon,
catalogs.coordinates.galactic?.e_lon,
schema.units.coordinates?.galactic?.lon,
2,
),
},
{
Parameter: "Galactic b",
Value: formatValueWithError(
catalogs.coordinates.galactic?.lat,
catalogs.coordinates.galactic?.e_lat,
schema.units.coordinates?.galactic?.lat,
2,
),
},
);
}

return (
<div className="space-y-6">
{object.catalogs?.coordinates && (
<CommonTable columns={coordinatesColumns} data={coordinatesData}>
<h2 className="text-xl font-bold">Coordinates</h2>
<p className="text-gray-300">Celestial coordinates of the object</p>
</CommonTable>
)}
if (catalogs?.redshift) {
data.push({
Parameter: "Redshift z",
Value: formatValueWithError(
catalogs.redshift.z,
catalogs.redshift.e_z,
undefined,
5,
),
});
}

{object.catalogs?.redshift && (
<CommonTable columns={redshiftColumns} data={redshiftData}>
<h2 className="text-xl font-bold">Redshift</h2>
<p className="text-gray-300">Redshift measurements</p>
</CommonTable>
)}
if (catalogs?.velocity) {
data.push(
{
Parameter: "Heliocentric Velocity",
Value: formatValueWithError(
catalogs.velocity.heliocentric?.v,
catalogs.velocity.heliocentric?.e_v,
schema.units.velocity?.heliocentric?.v,
),
},
{
Parameter: "Local Group Velocity",
Value: formatValueWithError(
catalogs.velocity.local_group?.v,
catalogs.velocity.local_group?.e_v,
schema.units.velocity?.local_group?.v,
),
},
{
Parameter: "CMB (old) Velocity",
Value: formatValueWithError(
catalogs.velocity.cmb_old?.v,
catalogs.velocity.cmb_old?.e_v,
schema.units.velocity?.cmb_old?.v,
),
},
{
Parameter: "CMB Velocity",
Value: formatValueWithError(
catalogs.velocity.cmb?.v,
catalogs.velocity.cmb?.e_v,
schema.units.velocity?.cmb?.v,
),
},
);
}

{object.catalogs?.velocity && (
<CommonTable columns={velocityColumns} data={velocityData}>
<h2 className="text-xl font-bold">Velocity</h2>
<p className="text-gray-300">
Velocity measurements with respect to different apexes
</p>
</CommonTable>
)}
</div>
);
return <CommonTable columns={columns} data={data} />;
}
2 changes: 1 addition & 1 deletion src/components/ui/common-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function CommonTable({
{children && (
<div
className={classNames(
"mb-1 p-4 bg-gray-50 rounded-sm",
"mb-1 p-2 bg-gray-50 rounded-sm",
headerClassName,
)}
>
Expand Down
Loading